Matt Downey
Matt Downey

Reputation: 393

Angular 2 CLI, Can I test only certain SPEC, instead of all of them?

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 ?

Upvotes: 1

Views: 1085

Answers (2)

yurzui
yurzui

Reputation: 214215

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$/);

Upvotes: 1

Eeks33
Eeks33

Reputation: 2315

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

Upvotes: 2

Related Questions