Johnniexson
Johnniexson

Reputation: 51

Running ng test for specific module

I have a fairly large Angular8 app I'm running unit test for, i would like the ng test command to run the test for only all spec.ts files within a specified/desired module and not for all spec.ts files in the entire codebase. I tried specifying the module name in the test.ts file path but it throws module not found error in terminal, but specifying a specific component name in the test.ts file runs the test for the single component but doesn't work for module. Thanks

Upvotes: 1

Views: 11116

Answers (2)

Ehsan
Ehsan

Reputation: 163

  1. navigate to src/app/test.ts.
  2. edit this line const context = require.context('<MODULE_PATH>', true, /.spec\.ts$/);

Upvotes: 2

Shai Reznik - HiRez.io
Shai Reznik - HiRez.io

Reputation: 8948

If you're using a newer version of Angular, you might use the --include as stated here and here

But if you're using Jasmine you can just add the letter "f" to your describe as so - fdescribe().

Or use it on the test itself - fit()

That way you "focus" on just one test or test suite and run only that.

Upvotes: 3

Related Questions