Testing files to only include specific folder for nx run-many

2.6k Views Asked by At

In package.json there is the following task:

{
  "test": "nx run-many --target=test --code-coverage --projects=myproject, anotherproject --parallel --maxParallel"
}

Now for just the Angular project 'myproject' I would like to run only in a specific folder.

That would be able with the command line argument: --test-path-pattern=\".*specific-folder($|.*.[spec.ts])\".

However, since I am running tasks in parallel setting such a command line argument would apply to all the projects rather than just one.

Is it possible to configure this in a different way?

1

There are 1 best solutions below

0
On

Via Jest config it's possible to target files/folders.

jest.config.ts

module.exports = {
  // ...
  testMatch: ['**/specific-folder/**/*.spec.ts'],
}

Either via testMatch or testRegex.

Now you can just run the project's tests and it will only target files in that folder.