Using create-nx-workspace --preset=angular-monorepo …
(or some similar Angular preset), how can I opt for Karma/Jasmine instead of Jest/Cypress (using create-nx-workspace 15.x)? Is that possible at workspace level?
(I have seen https://github.com/nrwl/nx/issues/1572 which answers the question at the module level, but create-nx-workspace --unit-test-runner=…
seems to have no effect.)
Yes. In your project.json file use the karma executor:
targets: {
"test": {
"executor": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": ["zone.js", "zone.js/testing"],
"tsConfig": "apps/my-app/tsconfig.spec.json",
"karmaConfig": "karma.conf.js"
}
}
}
tsconfig.spec.json:
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": ["jasmine"]
},
"include": ["src/**/*.spec.ts", "src/**/*.d.ts"]
}