简体   繁体   中英

ng test not passing Jest CLI options any more in v14?

I am using Jest with Angular (instead of Karma). The angular.json file seems to be configured properly, as running ng test works.

According to this article :

You can specify Jest CLI options either in builder options (useful when it is a persistent config) or right to ng test as a parameter (useful when it is a one-timer).

For example to run a single test:

ng test --testNamePattern="My test suite My test case"

This was working before my v14 upgrade, but this is not the case any more. Now if I run:

ng test --testNamePattern="MyComponent"

I get:

Error: Unknown argument: testNamePattern
Angular CLI: 14.0.2
Node: 16.13.1
Package Manager: yarn 1.22.17 
OS: darwin arm64

Angular: 14.0.2
... animations, cdk, cli, common, compiler, compiler-cli, core
... elements, forms, language-service, platform-browser
... platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1400.2
@angular-devkit/build-angular   14.0.2
@angular-devkit/core            14.0.2
@angular-devkit/schematics      8.3.29
@schematics/angular             14.0.2
rxjs                            6.6.7
typescript                      4.7.4

Note: this is possibly a regression of the builder

Okay quoting @just-jeb from github

It's mentioned in the migration guide . It's a breaking change of Angular CLI, not the builder. camelCase arguments are no longer supported.

Here is therefore the proper way to run the "MyComponent" test

ng test --test-name-pattern="MyComponent"

Note: Jetbrains does not yet (28.06.2022) supports the kebab case arguments

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM