nx/packages/angular/src/generators/application/lib/add-unit-test-runner.ts

25 lines
805 B
TypeScript

import type { Tree } from '@nrwl/devkit';
import type { NormalizedSchema } from './normalized-schema';
import { jestProjectGenerator } from '@nrwl/jest';
import { UnitTestRunner } from '../../../utils/test-runners';
import karmaProjectGenerator from '../../karma-project/karma-project';
export async function addUnitTestRunner(host: Tree, options: NormalizedSchema) {
if (options.unitTestRunner === UnitTestRunner.Jest) {
await jestProjectGenerator(host, {
project: options.name,
setupFile: 'angular',
supportTsx: false,
skipSerializers: false,
skipPackageJson: options.skipPackageJson,
});
} else if (options.unitTestRunner === UnitTestRunner.Karma) {
await karmaProjectGenerator(host, {
project: options.name,
skipFormat: true,
});
}
}