Skip to content

Commit

Permalink
fix(angular): unit test runner none should skip tests (#14916)
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 committed Feb 10, 2023
1 parent db7ee99 commit 066c3b1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
getWorkspaceLayout,
joinPathFragments,
names,
readJson,
Tree,
} from '@nrwl/devkit';
import type { Schema } from '../schema';
Expand Down Expand Up @@ -59,7 +58,7 @@ export function normalizeOptions(
routing: false,
inlineStyle: false,
inlineTemplate: false,
skipTests: false,
skipTests: options.unitTestRunner === UnitTestRunner.None,
skipFormat: false,
unitTestRunner: UnitTestRunner.Jest,
e2eTestRunner: E2eTestRunner.Cypress,
Expand Down
12 changes: 12 additions & 0 deletions packages/angular/src/generators/application/application.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ describe('app', () => {
expect(readProjectConfiguration(appTree, 'my-app-e2e')).toMatchSnapshot();
});

it('should not produce tests when UnitTestRunner = none', async () => {
// ACT
await generateApp(appTree, 'my-app', {
unitTestRunner: UnitTestRunner.None,
});
const { targets } = readProjectConfiguration(appTree, 'my-app');
expect(targets.test).toBeFalsy();
expect(
appTree.exists('apps/my-app/src/app/app.component.spec.ts')
).toBeFalsy();
});

it('should remove the e2e target on the application', async () => {
// ACT
await generateApp(appTree);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { extractLayoutDirectory, joinPathFragments, Tree } from '@nrwl/devkit';
import {
extractLayoutDirectory,
getWorkspaceLayout,
joinPathFragments,
names,
Tree,
} from '@nrwl/devkit';
import type { Schema } from '../schema';
import type { NormalizedSchema } from './normalized-schema';

import { names, getWorkspaceLayout } from '@nrwl/devkit';
import { E2eTestRunner, UnitTestRunner } from '../../../utils/test-runners';
import { Linter } from '@nrwl/linter';
import {
Expand Down Expand Up @@ -54,7 +58,7 @@ export function normalizeOptions(
routing: false,
inlineStyle: false,
inlineTemplate: false,
skipTests: false,
skipTests: options.unitTestRunner === UnitTestRunner.None,
skipFormat: false,
unitTestRunner: UnitTestRunner.Jest,
e2eTestRunner: E2eTestRunner.Cypress,
Expand Down

0 comments on commit 066c3b1

Please sign in to comment.