Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create Nx 15 workspace with Karma/Jasmine instead of Jest/Cypress

Tags:

nrwl-nx

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.)

like image 853
Christian Fuchs Avatar asked Oct 17 '25 15:10

Christian Fuchs


1 Answers

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"]
}
like image 169
jlooooo Avatar answered Oct 22 '25 07:10

jlooooo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!