How to use mkdirSync method in Jest

Best JavaScript code snippet using jest

resolveCache.js

Source:resolveCache.js Github

copy

Full Screen

...281 var source = String(Math.random());282 var sourceId = md5(source);283 var sourceDir = path.join(cacheDir, sourceId);284 // Create some versions285 fs.mkdirSync(sourceDir);286 fs.mkdirSync(path.join(sourceDir, '0.0.1'));287 fs.mkdirSync(path.join(sourceDir, '0.1.0'));288 fs.mkdirSync(path.join(sourceDir, 'foo'));289 resolveCache.versions(source)290 .then(function (versions) {291 expect(versions).to.not.contain('foo');292 expect(versions).to.contain('0.0.1');293 expect(versions).to.contain('0.1.0');294 next();295 })296 .done();297 });298 it('should order the versions', function (next) {299 var source = String(Math.random());300 var sourceId = md5(source);301 var sourceDir = path.join(cacheDir, sourceId);302 // Create some versions303 fs.mkdirSync(sourceDir);304 fs.mkdirSync(path.join(sourceDir, '0.0.1'));305 fs.mkdirSync(path.join(sourceDir, '0.1.0'));306 fs.mkdirSync(path.join(sourceDir, '0.1.0-rc.1'));307 resolveCache.versions(source)308 .then(function (versions) {309 expect(versions).to.eql(['0.1.0', '0.1.0-rc.1', '0.0.1']);310 next();311 })312 .done();313 });314 it('should cache versions to speed-up subsequent calls', function (next) {315 var source = String(Math.random());316 var sourceId = md5(source);317 var sourceDir = path.join(cacheDir, sourceId);318 // Create some versions319 fs.mkdirSync(sourceDir);320 fs.mkdirSync(path.join(sourceDir, '0.0.1'));321 resolveCache.versions(source)322 .then(function () {323 // Remove folder324 rimraf.sync(sourceDir);325 return resolveCache.versions(source);326 })327 .then(function (versions) {328 expect(versions).to.eql(['0.0.1']);329 next();330 })331 .done();332 });333 });334 describe('.retrieve', function () {335 it('should resolve to empty if there are no packages for the requested source', function (next) {336 resolveCache.retrieve(String(Math.random()))337 .spread(function () {338 expect(arguments.length).to.equal(0);339 next();340 })341 .done();342 });343 it('should resolve to empty if there are no suitable packages for the requested target', function (next) {344 var source = String(Math.random());345 var sourceId = md5(source);346 var sourceDir = path.join(cacheDir, sourceId);347 // Create some versions348 fs.mkdirSync(sourceDir);349 fs.mkdirSync(path.join(sourceDir, '0.0.1'));350 fs.mkdirSync(path.join(sourceDir, '0.1.0'));351 fs.mkdirSync(path.join(sourceDir, '0.1.9'));352 fs.mkdirSync(path.join(sourceDir, '0.2.0'));353 resolveCache.retrieve(source, '~0.3.0')354 .spread(function () {355 expect(arguments.length).to.equal(0);356 return resolveCache.retrieve(source, 'some-branch');357 })358 .spread(function () {359 expect(arguments.length).to.equal(0);360 next();361 })362 .done();363 });364 it('should remove invalid packages from the cache if their package meta is missing or invalid', function (next) {365 var source = String(Math.random());366 var sourceId = md5(source);367 var sourceDir = path.join(cacheDir, sourceId);368 // Create some versions369 fs.mkdirSync(sourceDir);370 fs.mkdirSync(path.join(sourceDir, '0.0.1'));371 fs.mkdirSync(path.join(sourceDir, '0.1.0'));372 fs.mkdirSync(path.join(sourceDir, '0.1.9'));373 fs.mkdirSync(path.join(sourceDir, '0.2.0'));374 // Create an invalid package meta375 fs.writeFileSync(path.join(sourceDir, '0.2.0', '.bower.json'), 'w00t');376 resolveCache.retrieve(source, '~0.1.0')377 .spread(function () {378 var dirs = fs.readdirSync(sourceDir);379 expect(arguments.length).to.equal(0);380 expect(dirs).to.contain('0.0.1');381 expect(dirs).to.contain('0.2.0');382 next();383 })384 .done();385 });386 it('should resolve to the highest package that matches a range target, ignoring pre-releases', function (next) {387 var source = String(Math.random());388 var sourceId = md5(source);389 var sourceDir = path.join(cacheDir, sourceId);390 var json = { name: 'foo' };391 // Create some versions392 fs.mkdirSync(sourceDir);393 json.version = '0.0.1';394 fs.mkdirSync(path.join(sourceDir, '0.0.1'));395 fs.writeFileSync(path.join(sourceDir, '0.0.1', '.bower.json'), JSON.stringify(json, null, ' '));396 json.version = '0.1.0';397 fs.mkdirSync(path.join(sourceDir, '0.1.0'));398 fs.writeFileSync(path.join(sourceDir, '0.1.0', '.bower.json'), JSON.stringify(json, null, ' '));399 json.version = '0.1.0-rc.1';400 fs.mkdirSync(path.join(sourceDir, '0.1.0-rc.1'));401 fs.writeFileSync(path.join(sourceDir, '0.1.0-rc.1', '.bower.json'), JSON.stringify(json, null, ' '));402 json.version = '0.1.9';403 fs.mkdirSync(path.join(sourceDir, '0.1.9'));404 fs.writeFileSync(path.join(sourceDir, '0.1.9', '.bower.json'), JSON.stringify(json, null, ' '));405 json.version = '0.2.0';406 fs.mkdirSync(path.join(sourceDir, '0.2.0'));407 fs.writeFileSync(path.join(sourceDir, '0.2.0', '.bower.json'), JSON.stringify(json, null, ' '));408 resolveCache.retrieve(source, '~0.1.0')409 .spread(function (canonicalDir, pkgMeta) {410 expect(pkgMeta).to.be.an('object');411 expect(pkgMeta.version).to.equal('0.1.9');412 expect(canonicalDir).to.equal(path.join(sourceDir, '0.1.9'));413 return resolveCache.retrieve(source, '*');414 })415 .spread(function (canonicalDir, pkgMeta) {416 expect(pkgMeta).to.be.an('object');417 expect(pkgMeta.version).to.equal('0.2.0');418 expect(canonicalDir).to.equal(path.join(sourceDir, '0.2.0'));419 next();420 })421 .done();422 });423 it('should resolve to the highest package that matches a range target, not ignoring pre-releases if they are the only versions', function (next) {424 var source = String(Math.random());425 var sourceId = md5(source);426 var sourceDir = path.join(cacheDir, sourceId);427 var json = { name: 'foo' };428 // Create some versions429 fs.mkdirSync(sourceDir);430 json.version = '0.1.0-rc.1';431 fs.mkdirSync(path.join(sourceDir, '0.1.0-rc.1'));432 fs.writeFileSync(path.join(sourceDir, '0.1.0-rc.1', '.bower.json'), JSON.stringify(json, null, ' '));433 json.version = '0.1.0-rc.2';434 fs.mkdirSync(path.join(sourceDir, '0.1.0-rc.2'));435 fs.writeFileSync(path.join(sourceDir, '0.1.0-rc.2', '.bower.json'), JSON.stringify(json, null, ' '));436 resolveCache.retrieve(source, '~0.1.0')437 .spread(function (canonicalDir, pkgMeta) {438 expect(pkgMeta).to.be.an('object');439 expect(pkgMeta.version).to.equal('0.1.0-rc.2');440 expect(canonicalDir).to.equal(path.join(sourceDir, '0.1.0-rc.2'));441 next();442 })443 .done();444 });445 it('should resolve to exact match (including build metadata) if available', function (next) {446 var source = String(Math.random());447 var sourceId = md5(source);448 var sourceDir = path.join(cacheDir, sourceId);449 var json = { name: 'foo' };450 // Create some versions451 fs.mkdirSync(sourceDir);452 json.version = '0.1.0';453 fs.mkdirSync(path.join(sourceDir, '0.1.0'));454 fs.writeFileSync(path.join(sourceDir, '0.1.0', '.bower.json'), JSON.stringify(json, null, ' '));455 json.version = '0.1.0+build.4';456 fs.mkdirSync(path.join(sourceDir, '0.1.0+build.4'));457 fs.writeFileSync(path.join(sourceDir, '0.1.0+build.4', '.bower.json'), JSON.stringify(json, null, ' '));458 json.version = '0.1.0+build.5';459 fs.mkdirSync(path.join(sourceDir, '0.1.0+build.5'));460 fs.writeFileSync(path.join(sourceDir, '0.1.0+build.5', '.bower.json'), JSON.stringify(json, null, ' '));461 json.version = '0.1.0+build.6';462 fs.mkdirSync(path.join(sourceDir, '0.1.0+build.6'));463 fs.writeFileSync(path.join(sourceDir, '0.1.0+build.6', '.bower.json'), JSON.stringify(json, null, ' '));464 resolveCache.retrieve(source, '0.1.0+build.5')465 .spread(function (canonicalDir, pkgMeta) {466 expect(pkgMeta).to.be.an('object');467 expect(pkgMeta.version).to.equal('0.1.0+build.5');468 expect(canonicalDir).to.equal(path.join(sourceDir, '0.1.0+build.5'));469 next();470 })471 .done();472 });473 it('should resolve to the _wildcard package if target is * and there are no semver versions', function (next) {474 var source = String(Math.random());475 var sourceId = md5(source);476 var sourceDir = path.join(cacheDir, sourceId);477 var json = { name: 'foo' };478 // Create some versions479 fs.mkdirSync(sourceDir);480 fs.mkdirSync(path.join(sourceDir, '_wildcard'));481 fs.writeFileSync(path.join(sourceDir, '_wildcard', '.bower.json'), JSON.stringify(json, null, ' '));482 resolveCache.retrieve(source, '*')483 .spread(function (canonicalDir, pkgMeta) {484 expect(pkgMeta).to.be.an('object');485 expect(canonicalDir).to.equal(path.join(sourceDir, '_wildcard'));486 next();487 })488 .done();489 });490 it('should resolve to the exact target it\'s not a semver range', function (next) {491 var source = String(Math.random());492 var sourceId = md5(source);493 var sourceDir = path.join(cacheDir, sourceId);494 var json = { name: 'foo' };495 // Create some versions496 fs.mkdirSync(sourceDir);497 fs.mkdirSync(path.join(sourceDir, 'some-branch'));498 fs.writeFileSync(path.join(sourceDir, 'some-branch', '.bower.json'), JSON.stringify(json, null, ' '));499 fs.mkdirSync(path.join(sourceDir, 'other-branch'));500 fs.writeFileSync(path.join(sourceDir, 'other-branch', '.bower.json'), JSON.stringify(json, null, ' '));501 resolveCache.retrieve(source, 'some-branch')502 .spread(function (canonicalDir, pkgMeta) {503 expect(pkgMeta).to.be.an('object');504 expect(pkgMeta).to.not.have.property('version');505 next();506 })507 .done();508 });509 });510 describe('.eliminate', function () {511 beforeEach(function () {512 mkdirp.sync(cacheDir);513 });514 it('should delete the source-md5/version folder', function (next) {515 var source = String(Math.random());516 var sourceId = md5(source);517 var sourceDir = path.join(cacheDir, sourceId);518 // Create some versions519 fs.mkdirSync(sourceDir);520 fs.mkdirSync(path.join(sourceDir, '0.0.1'));521 fs.mkdirSync(path.join(sourceDir, '0.1.0'));522 resolveCache.eliminate({523 name: 'foo',524 version: '0.0.1',525 _source: source,526 _target: '*'527 })528 .then(function () {529 expect(fs.existsSync(path.join(sourceDir, '0.0.1'))).to.be(false);530 expect(fs.existsSync(path.join(sourceDir, '0.1.0'))).to.be(true);531 next();532 })533 .done();534 });535 it('should delete the source-md5/target folder', function (next) {536 var source = String(Math.random());537 var sourceId = md5(source);538 var sourceDir = path.join(cacheDir, sourceId);539 // Create some versions540 fs.mkdirSync(sourceDir);541 fs.mkdirSync(path.join(sourceDir, '0.0.1'));542 fs.mkdirSync(path.join(sourceDir, 'some-branch'));543 resolveCache.eliminate({544 name: 'foo',545 _source: source,546 _target: 'some-branch'547 })548 .then(function () {549 expect(fs.existsSync(path.join(sourceDir, 'some-branch'))).to.be(false);550 expect(fs.existsSync(path.join(sourceDir, '0.0.1'))).to.be(true);551 next();552 })553 .done();554 });555 it('should delete the source-md5/_wildcard folder', function (next) {556 var source = String(Math.random());557 var sourceId = md5(source);558 var sourceDir = path.join(cacheDir, sourceId);559 // Create some versions560 fs.mkdirSync(sourceDir);561 fs.mkdirSync(path.join(sourceDir, '0.0.1'));562 fs.mkdirSync(path.join(sourceDir, '_wildcard'));563 resolveCache.eliminate({564 name: 'foo',565 _source: source,566 _target: '*'567 })568 .then(function () {569 expect(fs.existsSync(path.join(sourceDir, '_wildcard'))).to.be(false);570 expect(fs.existsSync(path.join(sourceDir, '0.0.1'))).to.be(true);571 next();572 })573 .done();574 });575 it('should delete the source-md5 folder if empty', function (next) {576 var source = String(Math.random());577 var sourceId = md5(source);578 var sourceDir = path.join(cacheDir, sourceId);579 // Create some versions580 fs.mkdirSync(sourceDir);581 fs.mkdirSync(path.join(sourceDir, '0.0.1'));582 resolveCache.eliminate({583 name: 'foo',584 version: '0.0.1',585 _source: source,586 _target: '*'587 })588 .then(function () {589 expect(fs.existsSync(path.join(sourceDir, '0.0.1'))).to.be(false);590 expect(fs.existsSync(path.join(sourceDir))).to.be(false);591 next();592 })593 .done();594 });595 it('should remove entry from in memory cache if the source-md5 folder was deleted', function (next) {596 var source = String(Math.random());597 var sourceId = md5(source);598 var sourceDir = path.join(cacheDir, sourceId);599 // Create some versions600 fs.mkdirSync(sourceDir);601 fs.mkdirSync(path.join(sourceDir, '0.0.1'));602 // Feed up the cache603 resolveCache.versions(source)604 // Eliminate605 .then(function () {606 return resolveCache.eliminate({607 name: 'foo',608 version: '0.0.1',609 _source: source,610 _target: '*'611 });612 })613 .then(function () {614 // At this point the parent folder should be deleted615 // To test against the in-memory cache, we create a folder616 // manually and request the versions617 mkdirp.sync(path.join(sourceDir, '0.0.2'));618 resolveCache.versions(source)619 .then(function (versions) {620 expect(versions).to.eql(['0.0.2']);621 next();622 });623 })624 .done();625 });626 });627 describe('.clear', function () {628 beforeEach(function () {629 mkdirp.sync(cacheDir);630 });631 it('should empty the whole cache folder', function (next) {632 resolveCache.clear()633 .then(function () {634 var files;635 expect(fs.existsSync(cacheDir)).to.be(true);636 files = fs.readdirSync(cacheDir);637 expect(files.length).to.be(0);638 next();639 })640 .done();641 });642 it('should erase the in-memory cache', function (next) {643 var source = String(Math.random());644 var sourceId = md5(source);645 var sourceDir = path.join(cacheDir, sourceId);646 // Create some versions647 fs.mkdirSync(sourceDir);648 fs.mkdirSync(path.join(sourceDir, '0.0.1'));649 // Feed the in-memory cache650 resolveCache.versions(source)651 // Clear652 .then(function () {653 return resolveCache.clear();654 })655 .then(function () {656 // To test against the in-memory cache, we create a folder657 // manually and request the versions658 mkdirp.sync(path.join(sourceDir, '0.0.2'));659 resolveCache.versions(source)660 .then(function (versions) {661 expect(versions).to.eql(['0.0.2']);662 next();663 });664 })665 .done();666 });667 });668 describe('.reset', function () {669 it('should erase the in-memory cache', function (next) {670 var source = String(Math.random());671 var sourceId = md5(source);672 var sourceDir = path.join(cacheDir, sourceId);673 // Create some versions674 fs.mkdirSync(sourceDir);675 fs.mkdirSync(path.join(sourceDir, '0.0.1'));676 // Feed the in-memory cache677 resolveCache.versions(source)678 .then(function () {679 // Delete 0.0.1 and create 0.0.2680 fs.rmdirSync(path.join(sourceDir, '0.0.1'));681 fs.mkdirSync(path.join(sourceDir, '0.0.2'));682 // Reset cache683 resolveCache.reset();684 // Get versions685 return resolveCache.versions(source);686 })687 .then(function (versions) {688 expect(versions).to.eql(['0.0.2']);689 next();690 })691 .done();692 });693 });694 describe('.list', function () {695 beforeEach(function () {696 rimraf.sync(cacheDir);697 mkdirp.sync(cacheDir);698 });699 it('should resolve to an empty array if the cache is empty', function (next) {700 resolveCache.list()701 .then(function (entries) {702 expect(entries).to.be.an('array');703 expect(entries.length).to.be(0);704 next();705 })706 .done();707 });708 it('should resolve to an ordered array of entries (name ASC, release ASC)', function (next) {709 var source = 'list-package-1';710 var sourceId = md5(source);711 var sourceDir = path.join(cacheDir, sourceId);712 var source2 = 'list-package-2';713 var sourceId2 = md5(source2);714 var sourceDir2 = path.join(cacheDir, sourceId2);715 var json = {716 name: 'foo'717 };718 // Create some versions for different sources719 fs.mkdirSync(sourceDir);720 fs.mkdirSync(path.join(sourceDir, '0.0.1'));721 json.version = '0.0.1';722 fs.writeFileSync(path.join(sourceDir, '0.0.1', '.bower.json'), JSON.stringify(json, null, ' '));723 fs.mkdirSync(path.join(sourceDir, '0.1.0'));724 json.version = '0.1.0';725 fs.writeFileSync(path.join(sourceDir, '0.1.0', '.bower.json'), JSON.stringify(json, null, ' '));726 delete json.version;727 fs.mkdirSync(path.join(sourceDir, 'foo'));728 json._target = 'foo';729 fs.writeFileSync(path.join(sourceDir, 'foo', '.bower.json'), JSON.stringify(json, null, ' '));730 fs.mkdirSync(path.join(sourceDir, 'bar'));731 json._target = 'bar';732 fs.writeFileSync(path.join(sourceDir, 'bar', '.bower.json'), JSON.stringify(json, null, ' '));733 fs.mkdirSync(path.join(sourceDir, 'aa'));734 json._target = 'aa';735 fs.writeFileSync(path.join(sourceDir, 'aa', '.bower.json'), JSON.stringify(json, null, ' '));736 delete json._target;737 fs.mkdirSync(sourceDir2);738 fs.mkdirSync(path.join(sourceDir2, '0.2.1'));739 json.version = '0.2.1';740 fs.writeFileSync(path.join(sourceDir2, '0.2.1', '.bower.json'), JSON.stringify(json, null, ' '));741 fs.mkdirSync(path.join(sourceDir2, '0.2.0'));742 json.name = 'abc';743 json.version = '0.2.0';744 fs.writeFileSync(path.join(sourceDir2, '0.2.0', '.bower.json'), JSON.stringify(json, null, ' '));745 resolveCache.list()746 .then(function (entries) {747 var expectedJson;748 var bowerDir = path.join(__dirname, '../..');749 expect(entries).to.be.an('array');750 expectedJson = fs.readFileSync(path.join(__dirname, '../assets/resolve-cache/list-json-1.json'));751 expectedJson = expectedJson.toString();752 mout.object.forOwn(entries, function (entry) {753 // Trim absolute bower path from json754 entry.canonicalDir = entry.canonicalDir.substr(bowerDir.length);755 // Convert windows \ paths to /756 entry.canonicalDir = entry.canonicalDir.replace(/\\/g, '/');757 });758 json = JSON.stringify(entries, null, ' ');759 expect(json).to.equal(expectedJson);760 next();761 })762 .done();763 });764 it('should ignore lurking files where dirs are expected', function (next) {765 var source = 'list-package-1';766 var sourceId = md5(source);767 var sourceDir = path.join(cacheDir, sourceId);768 var json = {769 name: 'foo'770 };771 // Create some versions772 fs.mkdirSync(sourceDir);773 fs.mkdirSync(path.join(sourceDir, '0.0.1'));774 json.version = '0.0.1';775 fs.writeFileSync(path.join(sourceDir, '0.0.1', '.bower.json'), JSON.stringify(json, null, ' '));776 // Create lurking files777 fs.writeFileSync(path.join(cacheDir, 'foo'), 'w00t');778 fs.writeFileSync(path.join(cacheDir, '.DS_Store'), '');779 fs.writeFileSync(path.join(sourceDir, 'foo'), 'w00t');780 fs.writeFileSync(path.join(sourceDir, '.DS_Store'), '');781 // It should not error out782 resolveCache.list()783 .then(function (entries) {784 expect(entries).to.be.an('array');785 expect(entries.length).to.be(1);786 expect(entries[0].pkgMeta).to.eql(json);787 // Lurking file should have been removed788 expect(fs.existsSync(path.join(cacheDir, 'foo'))).to.be(false);789 expect(fs.existsSync(path.join(cacheDir, '.DS_Store'))).to.be(false);790 expect(fs.existsSync(path.join(sourceDir, 'foo'))).to.be(false);791 expect(fs.existsSync(path.join(sourceDir, '.DS_Store'))).to.be(false);792 next();793 })794 .done();795 });796 it('should delete entries if failed to read package meta', function (next) {797 var source = 'list-package-1';798 var sourceId = md5(source);799 var sourceDir = path.join(cacheDir, sourceId);800 var json = {801 name: 'foo'802 };803 // Create invalid versions804 fs.mkdirSync(sourceDir);805 fs.mkdirSync(path.join(sourceDir, '0.0.1'));806 fs.mkdirSync(path.join(sourceDir, '0.0.2'));807 fs.writeFileSync(path.join(sourceDir, '0.0.2', '.bower.json'), 'w00t');808 // Create valid version809 fs.mkdirSync(path.join(sourceDir, '0.0.3'));810 json.version = '0.0.3';811 fs.writeFileSync(path.join(sourceDir, '0.0.3', '.bower.json'), JSON.stringify(json, null, ' '));812 // It should not error out813 resolveCache.list()814 .then(function (entries) {815 expect(entries).to.be.an('array');816 expect(entries.length).to.be(1);817 expect(entries[0].pkgMeta).to.eql(json);818 // Packages with invalid metas should have been removed819 expect(fs.existsSync(path.join(sourceDir, '0.0.1'))).to.be(false);820 expect(fs.existsSync(path.join(sourceDir, '0.0.2'))).to.be(false);821 next();822 })823 .done();824 });825 });826 describe('#clearRuntimeCache', function () {827 it('should clear the in-memory cache for all sources', function (next) {828 var source = String(Math.random());829 var sourceId = md5(source);830 var sourceDir = path.join(cacheDir, sourceId);831 var source2 = String(Math.random());832 var sourceId2 = md5(source2);833 var sourceDir2 = path.join(cacheDir, sourceId2);834 // Create some versions835 fs.mkdirSync(sourceDir);836 fs.mkdirSync(path.join(sourceDir, '0.0.1'));837 fs.mkdirSync(sourceDir2);838 fs.mkdirSync(path.join(sourceDir2, '0.0.2'));839 // Feed the cache840 resolveCache.versions(source)841 .then(function () {842 return resolveCache.versions(source2);843 })844 .then(function () {845 // Create some more846 fs.mkdirSync(path.join(sourceDir, '0.0.3'));847 fs.mkdirSync(path.join(sourceDir2, '0.0.4'));848 // Reset cache849 ResolveCache.clearRuntimeCache();850 })851 .then(function () {852 return resolveCache.versions(source)853 .then(function (versions) {854 expect(versions).to.eql(['0.0.3', '0.0.1']);855 return resolveCache.versions(source2);856 })857 .then(function (versions) {858 expect(versions).to.eql(['0.0.4', '0.0.2']);859 next();860 });861 })...

Full Screen

Full Screen

generate.js

Source:generate.js Github

copy

Full Screen

...143 frameworks.forEach((f) => {144 fs.rmdirSync(`dist-${f}/`, { recursive: true });145 });146 if (frameworks.includes("bootstrap")) {147 fs.mkdirSync("dist-bootstrap/bootstrap/", { recursive: true });148 }149 if (frameworks.includes("mdi")) {150 fs.mkdirSync("dist-mdi/mdi/", { recursive: true });151 }152 if (frameworks.includes("fontawesome")) {153 fs.mkdirSync("dist-fontawesome/fontawesome/", { recursive: true });154 fs.mkdirSync("dist-fontawesome/fontawesome/brands");155 fs.mkdirSync("dist-fontawesome/fontawesome/regular");156 fs.mkdirSync("dist-fontawesome/fontawesome/solid");157 }158 if (frameworks.includes("phosphor")) {159 fs.mkdirSync("dist-phosphor/phosphor/", { recursive: true });160 fs.mkdirSync("dist-phosphor/phosphor/Bold");161 fs.mkdirSync("dist-phosphor/phosphor/Duotone");162 fs.mkdirSync("dist-phosphor/phosphor/Fill");163 fs.mkdirSync("dist-phosphor/phosphor/Light");164 fs.mkdirSync("dist-phosphor/phosphor/Regular");165 fs.mkdirSync("dist-phosphor/phosphor/Thin");166 }167 if (frameworks.includes("remix")) {168 let remixSub = [169 "Buildings",170 "Business",171 "Communication",172 "Design",173 "Development",174 "Device",175 "Document",176 "Editor",177 "Finance",178 "Health",179 "Logos",180 "Map",181 "Media",182 "Others",183 "System",184 "User",185 "Weather",186 ];187 fs.mkdirSync("dist-remix/remix/", { recursive: true });188 remixSub.forEach((i) => {189 fs.mkdirSync("dist-remix/remix/" + i);190 });191 }192};193let finalizeDist = (dist, framework, index) => {194 fs.writeFileSync(path.join(dist, "index.js"), index);195 fs.copyFileSync(196 path.join("package", "package-" + framework + ".json"),197 path.join(dist, "package.json")198 );199};200const createComponents = (framework) => {201 const source = path.join("icons", framework);202 const dist = "dist-" + framework;203 const files = getFiles(source);...

Full Screen

Full Screen

index.test.js

Source:index.test.js Github

copy

Full Screen

...5const touch = require('touch')6const gitDirsSearch = require('../index')7const testDir = join(__dirname, 'testDir')8function createDirStructure () {9 mkdirSync(join(testDir))10 mkdirSync(join(testDir, 'a'))11 mkdirSync(join(testDir, 'a/.git'))12 mkdirSync(join(testDir, 'a/empty'))13 mkdirSync(join(testDir, 'a/empty/git'))14 mkdirSync(join(testDir, 'a/git'))15 mkdirSync(join(testDir, 'b'))16 mkdirSync(join(testDir, 'b/.git'))17 mkdirSync(join(testDir, 'b/git'))18 mkdirSync(join(testDir, 'b/git/git'))19 mkdirSync(join(testDir, 'b/node_modules'))20 mkdirSync(join(testDir, 'b/node_modules/a'))21 mkdirSync(join(testDir, 'b/node_modules/a/.git'))22 mkdirSync(join(testDir, 'b/node_modules/.git'))23 mkdirSync(join(testDir, 'c'))24 mkdirSync(join(testDir, 'c/.git'))25 touch(join(testDir, 'c/test.txt'))26 mkdirSync(join(testDir, 'd'))27 mkdirSync(join(testDir, 'd/d-a'))28 mkdirSync(join(testDir, 'd/d-a/.git'))29 mkdirSync(join(testDir, 'd/d-a/d-a-a'))30 mkdirSync(join(testDir, 'd/d-a/d-a-a/d-a-a-a'))31 mkdirSync(join(testDir, 'd/d-a/d-a-a/git'))32 mkdirSync(join(testDir, 'd/d-a/d-a-a/d-a-a-a/.git'))33 mkdirSync(join(testDir, 'e'))34 mkdirSync(join(testDir, 'e/git'))35 touch(join(testDir, 'e/test.txt'))36 mkdirSync(join(testDir, 'node_modules'))37 mkdirSync(join(testDir, 'node_modules/a'))38 mkdirSync(join(testDir, 'node_modules/a/.git'))39}40function clearDirStructure () {41 if (existsSync(testDir)) {42 rmRfSync(testDir)43 }44}45beforeAll(() => {46 clearDirStructure()47 return createDirStructure()48})49afterAll(() => {50 return clearDirStructure()51})52test('gitDirsSearch should be defined', () => {...

Full Screen

Full Screen

build.js

Source:build.js Github

copy

Full Screen

...89};90const getPathDist = () => {91 const pathDirOut = path.resolve(DIR_ACTUAL, DIR_DIST);92 if (fs.existsSync(pathDirOut)) deleteFolderRecursive(pathDirOut);93 fs.mkdirSync(pathDirOut);94 95 return pathDirOut;96};97const setPackage = (pathDist, package) => {98 const packageBuild = {99 name : package.name,100 version : package.version,101 description : package.description,102 main : package.main,103 scripts : {104 start : package.scripts.start,105 },106 keywords : package.keywords,107 author : package.author,108 license : package.license,109 dependencies : package.dependencies,110 };111 fs.writeFileSync(path.resolve(pathDist, "package.json"), JSON.stringify(packageBuild));112};113const setSubDirectorios = (pathDist) => {114 // fs.mkdirSync(path.resolve(pathDist, "app"));115 // fs.mkdirSync(path.resolve(pathDist, "app", "constants"));116 // fs.mkdirSync(path.resolve(pathDist, "app", "functions"));117 // fs.mkdirSync(path.resolve(pathDist, "app", "helpers"));118 // fs.mkdirSync(path.resolve(pathDist, "app", "hooks"));119 fs.mkdirSync(path.resolve(pathDist, "server"));120 // fs.mkdirSync(path.resolve(pathDist, "server", "controllers"));121 // fs.mkdirSync(path.resolve(pathDist, "server", "db"));122 // fs.mkdirSync(path.resolve(pathDist, "server", "helpers"));123 // fs.mkdirSync(path.resolve(pathDist, "server", "middlewares"));124 // fs.mkdirSync(path.resolve(pathDist, "server", "models"));125 // fs.mkdirSync(path.resolve(pathDist, "server", "routes"));126 // fs.mkdirSync(path.resolve(pathDist, "server", "services"));127 fs.mkdirSync(path.resolve(pathDist, "server", "public"));128 fs.mkdirSync(path.resolve(pathDist, "server", "public", "contents"));129 fs.mkdirSync(path.resolve(pathDist, "server", "public", "fonts"));130 fs.mkdirSync(path.resolve(pathDist, "server", "public", "images"));131 fs.mkdirSync(path.resolve(pathDist, "server", "public", "scripts"));132};133const setBuildNode = async () => {134 const { stdout, stderr } = await exec(`tsc`);135 136 console.log(stdout);137 if (stderr) console.log("Ocurrió un error en la compilación typeScript.");138 return { stdout, stderr };139};140const setBuildReact = async (modo) => {141 let ambiente = modo;142 if (modo == "dev") ambiente = "development";143 const { stdout, stderr } = await exec(`webpack --mode ${ambiente}`);144 145 console.log(stdout);...

Full Screen

Full Screen

builder.js

Source:builder.js Github

copy

Full Screen

...75 ├── util76 ├── view77 └── widget78 */79 fs.mkdirSync('asset');80 fs.mkdirSync('demo');81 fs.mkdirSync('demo/asset');82 fs.mkdirSync('doc');83 fs.mkdirSync('src');84 fs.mkdirSync('src/fonts');85 fs.mkdirSync('src/img');86 fs.mkdirSync('src/js');87 fs.mkdirSync('src/js/common');88 fs.mkdirSync('src/js/conf');89 fs.mkdirSync('src/js/general');90 fs.mkdirSync('src/js/lib');91 fs.mkdirSync('src/js/page');92 fs.mkdirSync('src/js/tpl');93 fs.mkdirSync('src/js/util');94 fs.mkdirSync('src/style');95 fs.mkdirSync('src/style/base');96 fs.mkdirSync('src/style/icon');97 fs.mkdirSync('src/style/page');98 fs.mkdirSync('src/style/util');99 fs.mkdirSync('src/style/view');100 fs.mkdirSync('src/style/widget');101 // js lib: jquery102 switch (yeoman.data.js.jquery){103 case 1:104 yeoman.template(mixPath('common/jquery-1.11.3.js'), 'src/js/lib/jquery-1.11.3.js');105 break;106 case 2:107 yeoman.template(mixPath('common/jquery-2.1.4.js'), 'src/js/lib/jquery-2.1.4.js');108 break;109 }110 break;111 default :112 break;113 }114};

Full Screen

Full Screen

framework_install.js

Source:framework_install.js Github

copy

Full Screen

...78 }79 var subpath = path.join(dir, subpaths[i]);80 stat = fs.statSync(subpath);81 if (stat.isDirectory()) {82 mkdirSync(path.join(projectPath, subpath));83 copySync(subpath);84 } else if (stat.isFile()) {85 copyFileSync(subpath, path.join(projectPath, subpath))86 }87 }88};89var copyFileSync = function(from, to) {90 fs.writeFileSync(to, fs.readFileSync(from));91};92var mkdirSync = function(path) {93 console.log('导入: ' + path);94 try {95 fs.mkdirSync(path);96 } catch (e) {97 if (e.code != 'EEXIST') throw e;98 }99};100// 项目地址拼接101projectPath = path.join(projectPath, projectName);102// 创建项目目录103mkdirSync(projectPath);104mkdirSync(path.join(projectPath, 'assets'));105// 框架模块106mkdirSync(path.join(projectPath, 'assets/framework'));107copySync(frameworkPath);108// 项目模块109mkdirSync(path.join(projectPath, 'assets/res'));110mkdirSync(path.join(projectPath, 'assets/resources'));111mkdirSync(path.join(projectPath, 'assets/scene'));112mkdirSync(path.join(projectPath, 'assets/script'));113mkdirSync(path.join(projectPath, 'assets/script/core'));114mkdirSync(path.join(projectPath, 'assets/script/fix'));115mkdirSync(path.join(projectPath, 'assets/script/page'));116mkdirSync(path.join(projectPath, 'assets/script/pop'));117mkdirSync(path.join(projectPath, 'assets/script/prefab'));118mkdirSync(path.join(projectPath, 'assets/script/service'));119mkdirSync(path.join(projectPath, 'assets/script/util'));120// 模板文件121fs.writeFileSync(path.join(projectPath, 'project.json'), projectTmp);122fs.writeFileSync(path.join(projectPath, 'assets/script/core/Config.js'), confiTmp);123fs.writeFileSync(path.join(projectPath, 'assets/script/util/Util.js'), utilTmp);124fs.writeFileSync(path.join(projectPath, 'assets/script/service/Service.js'), serviceTmp);125fs.writeFileSync(path.join(projectPath, 'assets/script/service/ServiceConfig.js'), serviceConfigTmp);...

Full Screen

Full Screen

projectinit.js

Source:projectinit.js Github

copy

Full Screen

...25 JSONObject.starlight = false;26 }27 //Add Debug folder if it doesn't exist already28 if(!fs.existsSync(`${WorkingDirectory}/project/Debug`)){29 fs.mkdirSync(`${WorkingDirectory}/project/Debug/`);30 }31 //Set ProjectData to current version and save32 JSONObject.Version = parseInt(CurrentVersion, 10);33 fs.writeJSONSync(`${WorkingDirectory}/ProjectData.json`, JSONObject, {spaces: `\t`});34 return;35 },36 CreateProject: async function(WorkingDirectory){37 //Figure out project name from folder structure38 ProjectName = WorkingDirectory;39 ProjectName = ProjectName.slice(ProjectName.slice(0, ProjectName.length-1).lastIndexOf(`/`)+1, ProjectName.length-1);40 //Create JSON41 JSONObject = {42 Version: version.Version,43 PName: ProjectName,44 DumpStats: {45 Time: `N/A`,46 Amount: 0,47 isUndumped: true,48 Type: `N/A`49 },50 songs: {},51 dates: {},52 starlight: false53 }54 //Write to JSON file55 fs.writeJSONSync(WorkingDirectory+`/ProjectData.json`, JSONObject, {spaces: `\t`});56 57 //Create shortcut to open project in folder58 fs.writeFileSync(`${WorkingDirectory}/${ProjectName}.smoproj`,59 `This file type is a shortcut to open your project. Please make all .smoproj files use "run.bat" from SMO Project Manager`);60 //Check if folder directories already exist61 isRomfsExists = fs.existsSync('romfs');62 isProjectExists = fs.existsSync('project');63 //Create directories64 if(!isRomfsExists){65 fs.mkdirSync(`${WorkingDirectory}/romfs`);66 }67 if(!isProjectExists){68 fs.mkdirSync(`${WorkingDirectory}/project`);69 }70 //Create sub-directories71 fs.mkdirSync(`${WorkingDirectory}/project/Stages`);72 fs.mkdirSync(`${WorkingDirectory}/project/Objects`);73 fs.mkdirSync(`${WorkingDirectory}/project/CubeMaps`);74 fs.mkdirSync(`${WorkingDirectory}/project/Sound`);75 fs.mkdirSync(`${WorkingDirectory}/project/Sound/stream`);76 fs.mkdirSync(`${WorkingDirectory}/project/Sound/prefetch`);77 fs.mkdirSync(`${WorkingDirectory}/project/Effects`);78 fs.mkdirSync(`${WorkingDirectory}/project/UI`);79 fs.mkdirSync(`${WorkingDirectory}/project/Text`);80 fs.mkdirSync(`${WorkingDirectory}/project/Video`);81 fs.mkdirSync(`${WorkingDirectory}/project/System`);82 fs.mkdirSync(`${WorkingDirectory}/project/Shaders`);83 fs.mkdirSync(`${WorkingDirectory}/project/Events`);84 fs.mkdirSync(`${WorkingDirectory}/project/AllUserContent`);85 fs.mkdirSync(`${WorkingDirectory}/project/AllUserContent/Models`);86 fs.mkdirSync(`${WorkingDirectory}/project/AllUserContent/Images`);87 fs.mkdirSync(`${WorkingDirectory}/project/AllUserContent/Sounds`);88 //Return with JSON data89 return JSONObject;90 }...

Full Screen

Full Screen

FileStream.js

Source:FileStream.js Github

copy

Full Screen

...29 let companyAbout = `${uploads}/companyAbout`;30 let promotinalPics = `${uploads}/promotinalPics`;31 let certificates = `${uploads}/certificates`;32 if(!fs.existsSync(uploads)){33 fs.mkdirSync(uploads);34 fs.mkdirSync(admin);35 fs.mkdirSync(download);36 fs.mkdirSync(franchisee);37 fs.mkdirSync(offers);38 fs.mkdirSync(reps);39 fs.mkdirSync(temp);40 fs.mkdirSync(products);41 fs.mkdirSync(img);42 fs.mkdirSync(techDetails);43 fs.mkdirSync(vis);44 fs.mkdirSync(companyAbout);45 fs.mkdirSync(promotinalPics);46 fs.mkdirSync(certificates);47 }48 else{49 if(!fs.existsSync(admin)) fs.mkdirSync(admin);50 if(!fs.existsSync(download)) fs.mkdirSync(download);51 if(!fs.existsSync(franchisee)) fs.mkdirSync(franchisee);52 if(!fs.existsSync(offers)) fs.mkdirSync(offers);53 if(!fs.existsSync(reps)) fs.mkdirSync(reps);54 if(!fs.existsSync(temp)) fs.mkdirSync(temp);55 if(!fs.existsSync(companyAbout)) fs.mkdirSync(companyAbout);56 if(!fs.existsSync(promotinalPics)) fs.mkdirSync(promotinalPics);57 if(!fs.existsSync(certificates)) fs.mkdirSync(certificates);58 if(!fs.existsSync(products)) fs.mkdirSync(products);59 else{60 if(!fs.existsSync(img)) fs.mkdirSync(img);61 if(!fs.existsSync(techDetails)) fs.mkdirSync(techDetails);62 if(!fs.existsSync(vis)) fs.mkdirSync(vis);63 } 64 }...

Full Screen

Full Screen

Jest Testing Tutorial

LambdaTest’s Jest Testing Tutorial covers step-by-step guides around Jest with code examples to help you be proficient with the Jest framework. The Jest tutorial has chapters to help you learn right from the basics of Jest framework to code-based tutorials around testing react apps with Jest, perform snapshot testing, import ES modules and more.

Chapters

  1. What is Jest Framework
  2. Advantages of Jest - Jest has 3,898,000 GitHub repositories, as mentioned on its official website. Learn what makes Jest special and why Jest has gained popularity among the testing and developer community.
  3. Jest Installation - All the prerequisites and set up steps needed to help you start Jest automation testing.
  4. Using Jest with NodeJS Project - Learn how to leverage Jest framework to automate testing using a NodeJS Project.
  5. Writing First Test for Jest Framework - Get started with code-based tutorial to help you write and execute your first Jest framework testing script.
  6. Jest Vocabulary - Learn the industry renowned and official jargons of the Jest framework by digging deep into the Jest vocabulary.
  7. Unit Testing with Jest - Step-by-step tutorial to help you execute unit testing with Jest framework.
  8. Jest Basics - Learn about the most pivotal and basic features which makes Jest special.
  9. Jest Parameterized Tests - Avoid code duplication and fasten automation testing with Jest using parameterized tests. Parameterization allows you to trigger the same test scenario over different test configurations by incorporating parameters.
  10. Jest Matchers - Enforce assertions better with the help of matchers. Matchers help you compare the actual output with the expected one. Here is an example to see if the object is acquired from the correct class or not. -

|<p>it('check_object_of_Car', () => {</p><p> expect(newCar()).toBeInstanceOf(Car);</p><p> });</p>| | :- |

  1. Jest Hooks: Setup and Teardown - Learn how to set up conditions which needs to be followed by the test execution and incorporate a tear down function to free resources after the execution is complete.
  2. Jest Code Coverage - Unsure there is no code left unchecked in your application. Jest gives a specific flag called --coverage to help you generate code coverage.
  3. HTML Report Generation - Learn how to create a comprehensive HTML report based on your Jest test execution.
  4. Testing React app using Jest Framework - Learn how to test your react web-application with Jest framework in this detailed Jest tutorial.
  5. Test using LambdaTest cloud Selenium Grid - Run your Jest testing script over LambdaTest cloud-based platform and leverage parallel testing to help trim down your test execution time.
  6. Snapshot Testing for React Front Ends - Capture screenshots of your react based web-application and compare them automatically for visual anomalies with the help of Jest tutorial.
  7. Bonus: Import ES modules with Jest - ES modules are also known as ECMAScript modules. Learn how to best use them by importing in your Jest testing scripts.
  8. Jest vs Mocha vs Jasmine - Learn the key differences between the most popular JavaScript-based testing frameworks i.e. Jest, Mocha, and Jasmine.
  9. Jest FAQs(Frequently Asked Questions) - Explore the most commonly asked questions around Jest framework, with their answers.

Run Jest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful