I am working on an application that uses https://nx.dev/ and https://angular.dev/ and is configured with https://jestjs.io/ to run unit tests.
I normally use this command to generate new Angular libraries inside the project:
npx nx generate @nx/angular:library
When selecting "jest"
as unitTestRunner
(which is our default), it correctly configures the project.json
with a "test"
target as well as adding the necessary configuration files for unit testing (e.g. tsconfig.spec.json
, jest.config.ts
, test-setup.ts
and a placeholder test).
Unfortunately, many of the existing libraries in the project were generated without the test target and I would like to add them programmatically.
How can I achieve that?
In other words, I need a way to generate the testing configuration (i.e. change project.json
with a "test"
target and add the configuration files tsconfig.spec.json
, jest.config.ts
, test-setup.ts
) for all the libraries that currently do not have any "test"
target.