How to compile a specific .spec.ts file in angular?

591 Views Asked by At

I have an application with many components and spec files. Can I just compile a specific spec.ts files during the execution of ng test command?

My issue is that there are many syntax errors in the other spec.ts component files, so I am not able to run the test cases for a specific test file.

I tried prefixing the describe function name with f:

fdescribe and fit causes only functions marked this way to run, as there are still errors in the other spec file. The compiler throws error on the cmd and on the browser shows this message

KARMA V 6.3.9 - Connected;test:complete;

Incomplete: no specs found, , randomized with seed 1234

I even tried ng test --include *path to the spec file*, but this also throws same error as above.

How can I execute only specific spec.ts in the application?

1

There are 1 best solutions below

0
AliF50 On

In test.ts, you can try changing this Regex to be more specific to the unit tests you would like to run. The Regex is the third argument. Be sure to change it back too.

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