Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,923 changes: 1,109 additions & 814 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@types/node": ">=18.19.130",
"@vitest/coverage-v8": "^4.0.18",
"@yeoman/adapter": "^4.0.2",
"@yeoman/eslint": "0.2.0",
"@yeoman/eslint": "^1.0.0",
"coveralls": "^3.1.1",
"husky": "^9.1.7",
"jsdoc": "^4.0.5",
Expand Down
8 changes: 4 additions & 4 deletions src/run-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ export class RunContextBase<GeneratorType extends BaseGenerator = DefaultGenerat
*/
withArguments(arguments_: string | string[]): this {
const argumentsArray = typeof arguments_ === 'string' ? arguments_.split(' ') : arguments_;
assert(Array.isArray(argumentsArray), 'args should be either a string separated by spaces or an array');
assert.ok(Array.isArray(argumentsArray), 'args should be either a string separated by spaces or an array');
this.args = [...this.args, ...argumentsArray];
return this;
}
Expand Down Expand Up @@ -407,7 +407,7 @@ export class RunContextBase<GeneratorType extends BaseGenerator = DefaultGenerat
*/

withGenerators(dependencies: Dependency[]): this {
assert(Array.isArray(dependencies), 'dependencies should be an array');
assert.ok(Array.isArray(dependencies), 'dependencies should be an array');
return this.onEnvironment(async environment => {
for (const dependency of dependencies) {
if (typeof dependency === 'string') {
Expand Down Expand Up @@ -497,7 +497,7 @@ export class RunContextBase<GeneratorType extends BaseGenerator = DefaultGenerat
*/

withMockedGenerators(namespaces: string[]): this {
assert(Array.isArray(namespaces), 'namespaces should be an array');
assert.ok(Array.isArray(namespaces), 'namespaces should be an array');
const mockedGenerators = Object.fromEntries(namespaces.map(namespace => [namespace, this.mockedGeneratorFactory()]));
const dependencies: Dependency[] = Object.entries(mockedGenerators).map(([namespace, mock]) => [mock, { namespace }]);
Object.assign(this.mockedGenerators, mockedGenerators);
Expand All @@ -509,7 +509,7 @@ export class RunContextBase<GeneratorType extends BaseGenerator = DefaultGenerat
* @param localConfig - should look just like if called config.getAll()
*/
withLocalConfig(localConfig: any): this {
assert(typeof localConfig === 'object', 'config should be an object');
assert.ok(typeof localConfig === 'object', 'config should be an object');
return this.onGenerator(generator => (generator as any).config.defaults(localConfig));
}

Expand Down
2 changes: 1 addition & 1 deletion src/run-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ export default class RunResult<GeneratorType extends BaseGenerator = BaseGenerat
let match = false;
match = typeof regex === 'string' ? body.includes(regex) : regex.test(body);

assert(match, `${file} did not match '${regex}'. Contained:\n\n${body}`);
assert.ok(match, `${file} did not match '${regex}'. Contained:\n\n${body}`);
}
}

Expand Down
8 changes: 4 additions & 4 deletions test/helpers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ describe('yeoman-test', () => {
'return a RunContext object',
promisify(done => {
const context = helpers.run(helpers.createDummyGenerator());
assert(context instanceof RunContext);
assert.ok(context instanceof RunContext);
context.on('end', done);
}),
);
Expand All @@ -189,7 +189,7 @@ describe('yeoman-test', () => {
const context = helpers.run('simple:app').withEnvironment(environment => {
environment.register(require.resolve('./fixtures/generator-simple/app'));
});
assert(context instanceof RunContext);
assert.ok(context instanceof RunContext);
context.on('end', done);
}),
);
Expand Down Expand Up @@ -382,8 +382,8 @@ describe('yeoman-test', () => {
.run(helpers.createDummyGenerator())
.withFiles({ 'foo.txt': 'foo', 'foo.json': { foo: 'bar' } })
.commitFiles();
assert(existsSync(resolve(runResult.cwd, 'foo.txt')));
assert(existsSync(resolve(runResult.cwd, 'foo.json')));
assert.ok(existsSync(resolve(runResult.cwd, 'foo.txt')));
assert.ok(existsSync(resolve(runResult.cwd, 'foo.json')));
});
});

Expand Down
34 changes: 17 additions & 17 deletions test/run-context-environment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ describe('RunContext running environment', () => {
});

it('returns instanceof RunContext', () => {
assert(context instanceof RunContext);
assert.ok(context instanceof RunContext);
});

it('promises a RunResult', () => {
return context.run().then(runResult => {
assert(runResult instanceof RunResult);
assert.ok(runResult instanceof RunResult);
});
});

Expand All @@ -77,7 +77,7 @@ describe('RunContext running environment', () => {

it('passes newErrorHandler to the environment', () => {
return context.run().then(() => {
assert(context.env.options.newErrorHandler);
assert.ok(context.env.options.newErrorHandler);
});
});
});
Expand All @@ -92,7 +92,7 @@ describe('RunContext running environment', () => {

it('runs the generator', () => {
return context.run().then(() => {
assert(context.env.generatorTestExecuted);
assert.ok(context.env.generatorTestExecuted);
});
});
});
Expand All @@ -115,7 +115,7 @@ describe('RunContext running environment', () => {

it('runs the generator', () => {
return context.run().then(() => {
assert(context.generator.shouldRun);
assert.ok(context.generator.shouldRun);
});
});
});
Expand All @@ -136,7 +136,7 @@ describe('RunContext running environment', () => {

it('runs the generator', () => {
return context.run().then(() => {
assert(context.env.generatorTestExecuted);
assert.ok(context.env.generatorTestExecuted);
});
});
});
Expand All @@ -152,14 +152,14 @@ describe('RunContext running environment', () => {
});

it('registers every generator', () => {
assert(context.env.get('simple:app'));
assert(context.env.get('simple:composing'));
assert(context.env.get('simple:throwing'));
assert.ok(context.env.get('simple:app'));
assert.ok(context.env.get('simple:composing'));
assert.ok(context.env.get('simple:throwing'));
});

it('runs the generator', () => {
return context.run().then(() => {
assert(context.env.generatorTestExecuted);
assert.ok(context.env.generatorTestExecuted);
});
});
});
Expand All @@ -181,14 +181,14 @@ describe('RunContext running environment', () => {
});

it('registers every generator', () => {
assert(context.env.get('simple:app'));
assert(context.env.get('simple:composing'));
assert(context.env.get('simple:throwing'));
assert.ok(context.env.get('simple:app'));
assert.ok(context.env.get('simple:composing'));
assert.ok(context.env.get('simple:throwing'));
});

it('runs the generator', () => {
return context.run().then(() => {
assert(context.env.generatorTestExecuted);
assert.ok(context.env.generatorTestExecuted);
});
});
});
Expand All @@ -205,7 +205,7 @@ describe('RunContext running environment', () => {
return context.run().then(
() => assert.fail(),
error => {
assert(/throwing error/.test(error.message));
assert.ok(/throwing error/.test(error.message));
},
);
});
Expand All @@ -228,7 +228,7 @@ describe('RunContext running environment', () => {
.withArguments('simple:app')
.run()
.then(() => {
assert(context.env.generatorTestExecuted);
assert.ok(context.env.generatorTestExecuted);
});
});

Expand All @@ -239,7 +239,7 @@ describe('RunContext running environment', () => {
.then(
() => assert.fail(),
error => {
assert(/throwing error/.test(error.message));
assert.ok(/throwing error/.test(error.message));
},
);
});
Expand Down
32 changes: 16 additions & 16 deletions test/run-context.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('RunContext', () => {

context
.on('ready', async () => {
assert(await context.env.get('simple:app'));
assert.ok(await context.env.get('simple:app'));
})
.on('end', done);
}),
Expand Down Expand Up @@ -118,7 +118,7 @@ describe('RunContext', () => {
'accept generator constructor parameter (and assign gen:test as namespace)',
promisify(done => {
context.on('ready', async () => {
assert(await context.env.get('gen:test'));
assert.ok(await context.env.get('gen:test'));
done();
});
}),
Expand Down Expand Up @@ -176,7 +176,7 @@ describe('RunContext', () => {
context.cleanTestDirectory();
assert.fail();
} catch (error) {
assert(error.message.includes('Cleanup test dir called with false tmpdir option.'));
assert.ok(error.message.includes('Cleanup test dir called with false tmpdir option.'));
}
});

Expand Down Expand Up @@ -374,12 +374,12 @@ describe('RunContext', () => {
);

it('throws error at additional calls with dirPath', () => {
assert(context.inDir(temporaryDirectory));
assert.ok(context.inDir(temporaryDirectory));
try {
context.inDir(temporaryDirectory);
assert.fail();
} catch (error) {
assert(error.message.includes('Test directory has already been set.'));
assert.ok(error.message.includes('Test directory has already been set.'));
}
});
});
Expand Down Expand Up @@ -455,7 +455,7 @@ describe('RunContext', () => {
});

it('should set inDirSet & targetDirectory', () => {
assert(!context.targetDirectory);
assert.ok(!context.targetDirectory);
context.cd(temporaryDirectory);
assert.equal(context.targetDirectory, temporaryDirectory);
});
Expand All @@ -472,7 +472,7 @@ describe('RunContext', () => {
context.cd(path.join(temporaryDirectory, 'NOT_EXIST'));
assert.fail();
} catch (error) {
assert(error.message.includes(temporaryDirectory));
assert.ok(error.message.includes(temporaryDirectory));
}
});
});
Expand All @@ -494,7 +494,7 @@ describe('RunContext', () => {
promisify(done => {
const callback = mock.fn(function (dir) {
assert.equal(this, context);
assert(dir.includes(tempDirectory));
assert.ok(dir.includes(tempDirectory));
});

context.inTmpDir(callback).on('end', done);
Expand Down Expand Up @@ -735,8 +735,8 @@ describe('RunContext', () => {
describe('#withMockedGenerators()', () => {
it('creates mocked generator', async () => {
await context.withMockedGenerators(['foo:bar']).build();
assert(await context.env.get('foo:bar'));
assert(context.mockedGenerators['foo:bar']);
assert.ok(await context.env.get('foo:bar'));
assert.ok(context.mockedGenerators['foo:bar']);
});
});

Expand All @@ -745,22 +745,22 @@ describe('RunContext', () => {
'register paths',
promisify(done => {
context.withGenerators([require.resolve('./fixtures/generator-simple/app')]).on('ready', async () => {
assert(await context.env.get('simple:app'));
assert.ok(await context.env.get('simple:app'));
done();
});
}),
);

it('register paths with namespaces', async () => {
await context.withGenerators([[require.resolve('./fixtures/generator-simple/app'), { namespace: 'foo:bar' }]]).build();
assert(await context.env.get('foo:bar'));
assert.ok(await context.env.get('foo:bar'));
});

it(
'register mocked generator',
promisify(done => {
context.withGenerators([[helpers.createDummyGenerator(), { namespace: 'dummy:gen' }]]).on('ready', async () => {
assert(await context.env.get('dummy:gen'));
assert.ok(await context.env.get('dummy:gen'));
done();
});
}),
Expand All @@ -773,8 +773,8 @@ describe('RunContext', () => {
.withGenerators([require.resolve('./fixtures/generator-simple/app')])
.withGenerators([[helpers.createDummyGenerator(), { namespace: 'dummy:gen' }]])
.on('ready', async () => {
assert(await context.env.get('dummy:gen'));
assert(await context.env.get('simple:app'));
assert.ok(await context.env.get('dummy:gen'));
assert.ok(await context.env.get('simple:app'));
done();
});
}),
Expand Down Expand Up @@ -853,7 +853,7 @@ describe('RunContext', () => {
return environment;
})
.on('ready', async () => {
assert(await context.env.get('simple:app'));
assert.ok(await context.env.get('simple:app'));
done();
});
}),
Expand Down
4 changes: 2 additions & 2 deletions test/run-result-assertions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ describe('run-result-assertions', () => {
description: 'using memory fs',
options: { memFs },
verify(runResult) {
assert(runResult.fs);
assert.ok(runResult.fs);
},
},
{
description: 'using node fs',
verify(runResult) {
assert(!runResult.fs);
assert.ok(!runResult.fs);
},
},
]) {
Expand Down
4 changes: 2 additions & 2 deletions test/run-result.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,9 @@ describe('run-result', () => {

result.assertGeneratorComposedOnce(mockedNamespace);
result.assertGeneratorComposed(mockedNamespace);
assert(result.getGeneratorComposeCount(mockedNamespace) === 1);
assert.ok(result.getGeneratorComposeCount(mockedNamespace) === 1);
assert.equal(result.getComposedGenerators().length, 1);
assert(result.getComposedGenerators()[0] === mockedNamespace);
assert.ok(result.getComposedGenerators()[0] === mockedNamespace);

result.assertGeneratorNotComposed('another:gen');
});
Expand Down
Loading