如何使用 Karma/Jasmine 而不是 Jest/Cypress 创建 Nx 15 工作区

问题描述 投票:0回答:1

使用

create-nx-workspace --preset=angular-monorepo …
(或一些类似的 Angular 预设),我如何选择 Karma/Jasmine 而不是 Jest/Cypress(使用 create-nx-workspace 15.x)?这在工作区级别可能吗?

(我已经看到https://github.com/nrwl/nx/issues/1572它回答了模块级别的问题,但是

create-nx-workspace --unit-test-runner=…
似乎没有效果。)

nrwl-nx
1个回答
0
投票

是的。在您的project.json 文件中使用 karma 执行器:

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"]
}
© www.soinside.com 2019 - 2024. All rights reserved.