How to use assertDirExists method in root

Best JavaScript code snippet using root

init.spec.js

Source:init.spec.js Github

copy

Full Screen

...64 const args = [ testDirName ];65 it("creates the project dir if it doesn't exist", () => {66 mockFs();67 return init.run(args).then(() =>68 assertDirExists(original_dir, testDirName)69 );70 });71 it('moves into the project dir', () => {72 mockFs({ [testDirName]: { } });73 return init.run(args).then(() =>74 assert.equal(process.cwd(), `${original_dir}/${testDirName}`)75 );76 });77 describe('when the project dir is empty', () => {78 beforeEach('initialize mockfs', () => {79 mockFs({ [projectDir]: {} });80 });81 it('creates the src dir', () =>82 init.run(args).then(() =>83 assertDirExists(projectDir, 'src')));84 it('creates the dist dir', () =>85 init.run(args).then(() =>86 assertDirExists(projectDir, 'dist')));87 it('creates an example dist/index.html', () =>88 init.run(args).then(() =>89 assertFileExists(`${projectDir}/dist`, 'index.html')));90 it('creates the .hz dir', () =>91 init.run(args).then(() =>92 assertDirExists(projectDir, '.hz')));93 it('creates the .gitignore file', () =>94 init.run(args).then(() =>95 assertFileExists(`${projectDir}`, '.gitignore')));96 it('creates the .hz/config.toml file', () =>97 init.run(args).then(() =>98 assertFileExists(`${projectDir}/.hz`, 'config.toml')));99 it('creates the .hz/secrets.toml file', () =>100 init.run(args).then(() =>101 assertFileExists(`${projectDir}/.hz`, 'secrets.toml')));102 it('creates the .hz/schema.toml file', () =>103 init.run(args).then(() =>104 assertFileExists(`${projectDir}/.hz`, 'schema.toml')));105 });106 describe('when the project dir is not empty', () => {107 beforeEach('initialize mockfs', () => {108 mockFs({109 [projectDir]: {110 lib: { 'someFile.html': '<blink>Something</blink>' },111 },112 });113 });114 it("doesn't create the src dir", () =>115 init.run(args).then(() =>116 assertDirDoesntExist(projectDir, 'src')));117 it("doesn't create the dist dir", () =>118 init.run(args).then(() =>119 assertDirDoesntExist(projectDir, 'dist')));120 it("doesn't create an example dist/index.html", () => {121 fs.mkdirSync(`${projectDir}/dist`);122 return init.run(args).then(() =>123 assertFileDoesntExist(`${projectDir}/dist`, 'index.html')124 );125 });126 it("still creates the .hz dir if it doesn't exist", () =>127 init.run(args).then(() =>128 assertDirExists(projectDir, '.hz')));129 it("doesn't create the .hz dir if it already exists", () => {130 fs.mkdirSync(`${projectDir}/.hz`);131 const beforeMtime = fs.statSync(`${projectDir}/.hz`).birthtime.getTime();132 return init.run(args).then(() => {133 const afterMtime = fs.statSync(`${projectDir}/.hz`).birthtime.getTime();134 assert.equal(beforeMtime, afterMtime, '.hz was modified');135 });136 });137 it("creates a valid config.toml if it doesn't exist", () => {138 fs.mkdirSync(`${projectDir}/.hz`);139 return init.run(args).then(() => {140 assertFileExists(`${projectDir}/.hz`, 'config.toml');141 assertValidConfig(`${projectDir}/.hz/config.toml`);142 });143 });144 it("creates a valid secrets.toml if it doesn't exist", () => {145 fs.mkdirSync(`${projectDir}/.hz`);146 return init.run(args).then(() => {147 assertFileExists(`${projectDir}/.hz`, 'secrets.toml');148 assertValidSecrets(`${projectDir}/.hz/secrets.toml`);149 });150 });151 it("creates a valid schema.toml if it doesn't exist", () => {152 fs.mkdirSync(`${projectDir}/.hz`);153 return init.run(args).then(() => {154 assertFileExists(`${projectDir}/.hz`, 'schema.toml');155 // TODO: assertValidSchema(`${projectDir}/.hz/schema.toml`);156 });157 });158 it("doesn't touch the config.toml if it already exists", () => {159 fs.mkdirSync(`${projectDir}/.hz`);160 const filename = `${projectDir}/.hz/config.toml`;161 fs.appendFileSync(filename, '#Hoo\n');162 const beforeMtime = fs.statSync(filename).mtime.getTime();163 return init.run(args).then(() => {164 const afterMtime = fs.statSync(filename).mtime.getTime();165 assert.equal(beforeMtime, afterMtime);166 const afterContents = getFileString(filename);167 assert.equal('#Hoo\n', afterContents);168 });169 });170 it("doesn't touch the secrets.toml if it already exists", () => {171 fs.mkdirSync(`${projectDir}/.hz`);172 const filename = `${projectDir}/.hz/secrets.toml`;173 fs.appendFileSync(filename, '#Hoo\n');174 const beforeMtime = fs.statSync(filename).mtime.getTime();175 return init.run(args).then(() => {176 const afterMtime = fs.statSync(filename).mtime.getTime();177 assert.equal(beforeMtime, afterMtime);178 const afterContents = getFileString(filename);179 assert.equal('#Hoo\n', afterContents);180 });181 });182 it("doesn't touch the schema.toml if it already exists", () => {183 fs.mkdirSync(`${projectDir}/.hz`);184 const filename = `${projectDir}/.hz/schema.toml`;185 fs.appendFileSync(filename, '#Hoo\n');186 const beforeMtime = fs.statSync(filename).mtime.getTime();187 return init.run(args).then(() => {188 const afterMtime = fs.statSync(filename).mtime.getTime();189 assert.equal(beforeMtime, afterMtime);190 const afterContents = getFileString(filename);191 assert.equal('#Hoo\n', afterContents);192 });193 });194 });195 });196 describe('when not passed a project name', () => {197 const args = [ ];198 it('stays in the current directory', () => {199 mockFs();200 return init.run(args).then(() => {201 const afterCwd = process.cwd();202 assert.equal(original_dir, afterCwd, 'init changed directories');203 });204 });205 describe('in an empty directory', () => {206 beforeEach('initialize mockfs', () => mockFs({}));207 it('creates the src dir', () =>208 init.run(args).then(() =>209 assertDirExists(original_dir, 'src')));210 it('creates the dist dir', () =>211 init.run(args).then(() =>212 assertDirExists(original_dir, 'dist')));213 it('creates an example dist/index.html', () =>214 init.run(args).then(() =>215 assertFileExists(`${original_dir}/dist`, 'index.html')));216 it('creates the .hz dir', () =>217 init.run(args).then(() =>218 assertDirExists(original_dir, '.hz')));219 it('creates the .hz/config.toml file', () =>220 init.run(args).then(() => {221 assertFileExists(hz_dir, 'config.toml');222 assertValidConfig(`${hz_dir}/config.toml`);223 }));224 });225 describe('in a directory with files in it', () => {226 beforeEach('initialize mocks', () => {227 mockFs({228 lib: { 'some_file.txt': 'Some file content' },229 });230 });231 it("doesn't create the src dir", () =>232 init.run(args).then(() =>233 assertDirDoesntExist(original_dir, 'src')));234 it("doesn't create the dist dir", () =>235 init.run(args).then(() =>236 assertDirDoesntExist(original_dir, 'dist')));237 it("doesn't create an example dist/index.html", () => {238 fs.mkdirSync(`${original_dir}/dist`);239 return init.run(args).then(() =>240 assertFileDoesntExist(`${original_dir}/dist`, 'index.html')241 );242 });243 it("creates the .hz dir if it doesn't exist", () =>244 init.run(args).then(() =>245 assertDirExists(original_dir, '.hz')));246 it("doesn't create the .hz dir if it exists", () => {247 fs.mkdirSync(hz_dir);248 const beforeTime = fs.statSync(hz_dir).birthtime.getTime();249 return init.run(args).then(() => {250 assertDirExists(original_dir, '.hz');251 const afterTime = fs.statSync(hz_dir).birthtime.getTime();252 assert.equal(beforeTime, afterTime, '.hz birthtime changed');253 });254 });255 it("creates the config.toml if it doesn't exist", () =>256 init.run(args).then(() => {257 assertFileExists(hz_dir, 'config.toml');258 assertValidConfig(`${hz_dir}/config.toml`);259 })260 );261 it("doesn't touch the config.toml if it already exists", () => {262 fs.mkdirSync(hz_dir);263 const filename = `${hz_dir}/config.toml`;264 fs.appendFileSync(filename, '#Hoo\n');...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const assertDirExists = require('assert-dir-exists');2assertDirExists('test');3assertDirExists('test', 'test directory does not exist');4const assertDirExists = require('assert-dir-exists').assertDirExists;5assertDirExists('test');6assertDirExists('test', 'test directory does not exist');7const assertDirExists = require('assert-dir-exists').assertDirExists;8assertDirExists('test');9assertDirExists('test', 'test directory does not exist');10const assertDirExists = require('assert-dir-exists').assertDirExists;11assertDirExists('test');12assertDirExists('test', 'test directory does not exist');13const assertDirExists = require('assert-dir-exists').assertDirExists;14assertDirExists('test');15assertDirExists('test', 'test directory does not exist');16const assertDirExists = require('assert-dir-exists').assertDirExists;17assertDirExists('test');18assertDirExists('test', 'test directory does not exist');19const assertDirExists = require('assert-dir-exists').assertDirExists;20assertDirExists('test');21assertDirExists('test', 'test directory does not exist');22const assertDirExists = require('assert-dir-exists').assertDirExists;23assertDirExists('test');24assertDirExists('test', 'test directory does not exist');25const assertDirExists = require('assert-dir-exists').assertDirExists;26assertDirExists('test');27assertDirExists('test', 'test directory does not exist');28const assertDirExists = require('assert-dir-exists').assertDirExists;29assertDirExists('test');30assertDirExists('test', 'test directory does not exist');

Full Screen

Using AI Code Generation

copy

Full Screen

1var assertDirExists = require('./test.js');2assertDirExists('mydir');3var assertDirExists = require('./test.js');4assertDirExists('mydir/mydir2');5var assertDirExists = require('./test.js');6assertDirExists('mydir/mydir2');7var assertDirExists = require('./test.js');8assertDirExists('mydir/mydir2');9var assertDirExists = require('./test.js');10assertDirExists('mydir/mydir2');11var assertDirExists = require('./test.js');12assertDirExists('mydir/mydir2');13var assertDirExists = require('./test.js');14assertDirExists('mydir/mydir2');15var assertDirExists = require('./test.js');16assertDirExists('mydir/mydir2');17var assertDirExists = require('./test.js');18assertDirExists('mydir/mydir2');19var assertDirExists = require('./test.js');20assertDirExists('mydir/mydir2');21var assertDirExists = require('./test.js');22assertDirExists('mydir/mydir2');23var assertDirExists = require('./test.js');24assertDirExists('mydir/mydir2');25var assertDirExists = require('./test.js');26assertDirExists('mydir/mydir2');27var assertDirExists = require('./test.js');

Full Screen

Using AI Code Generation

copy

Full Screen

1var assertDirExists = require('./test.js').assertDirExists;2module.exports = {3}4var fs = require('fs');5var assertDirExists = function(dir) {6 if (!fs.existsSync(dir)) {7 fs.mkdirSync(dir);8 }9}10module.exports = {11}

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run root 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