Skip to content
Open
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
4 changes: 2 additions & 2 deletions actions/new.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ const mapContextToSchematicOptions = (
if (context.directory !== undefined)
options.push(new SchematicOption('directory', context.directory));

if (context.dryRun)
options.push(new SchematicOption('dry-run', true));
if (context.dryRun) options.push(new SchematicOption('dry-run', true));
options.push(new SchematicOption('skip-git', context.skipGit));
options.push(new SchematicOption('strict', context.strict));

if (context.skipTests) {
options.push(new SchematicOption('spec', false));
options.push(new SchematicOption('skipTesting', true));
}

if (context.packageManager !== undefined)
Expand Down
22 changes: 18 additions & 4 deletions test/actions/new.action.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ describe('NewAction', () => {
process.exit = originalExit;
});

const baseContext = (overrides: Partial<NewCommandContext> = {}): NewCommandContext => ({
const baseContext = (
overrides: Partial<NewCommandContext> = {},
): NewCommandContext => ({
name: 'test-project',
directory: undefined,
dryRun: false,
Expand Down Expand Up @@ -102,6 +104,19 @@ describe('NewAction', () => {
expect(specOption).toBeDefined();
});

it('should pass --skipTesting=true to schematics when --skip-tests is true', async () => {
const context = baseContext({ skipTests: true });
await action.handle(context);

expect(mockExecute).toHaveBeenCalledTimes(1);
const [, schematicOptions] = mockExecute.mock.calls[0];

const skipTestingOption = schematicOptions.find(
(opt: SchematicOption) => opt.toCommandString() === '--skip-testing',
);
expect(skipTestingOption).toBeDefined();
});

it('should not pass spec option to schematics when --skip-tests is false', async () => {
const context = baseContext({ skipTests: false });
await action.handle(context);
Expand All @@ -123,9 +138,8 @@ describe('NewAction', () => {

const [, schematicOptions] = mockExecute.mock.calls[0];

const skipTestsOption = schematicOptions.find(
(opt: SchematicOption) =>
opt.toCommandString().includes('skip-tests'),
const skipTestsOption = schematicOptions.find((opt: SchematicOption) =>
opt.toCommandString().includes('skip-tests'),
);
expect(skipTestsOption).toBeUndefined();
});
Expand Down