1

I'm using angular 2 CLI for my web project, and I wrote a lot of unit tests, as my code base grows larger, the tests become more and more heavier. I was wondering if it's possible to test only certain part of the spec files I specified ?

Matt Downey
  • 363
  • 6
  • 18

2 Answers2

2

You can manually turn off tests or just run specific tests, with the following syntax.

If you prefix "describe" blocks with an f, only that will run:

fdescribe()

If you prefix "it" blocks with an f, only that will run:

fit()

You can also prefix with an 'x' to not run a block: xit() and xdescribe()

See: How to execute only one test spec with angular-cli

Community
  • 1
  • 1
Eeks33
  • 2,245
  • 1
  • 14
  • 17
1

There is test.ts file

// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);

If i want to test only pipes i can write:

const context = require.context('./', true, /pipe\.spec\.ts$/);
yurzui
  • 205,937
  • 32
  • 433
  • 399