0

I have an Angular app in which i have many components. But for now I just want to run the tests for login.component.ts so for that I did in my test.ts file like this

const context = require.context('./', true, /login\.component\.spec\.ts$/);

But when I run ng test it runs all components' test files and gives an error on one of the directives I have like this:

enter image description here

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
ahsan
  • 277
  • 1
  • 5
  • 18
  • 1
    Why edit the test.ts file? Pass the --include argument to the test command (see https://angular.io/cli/test) or use fdescribe to focus your tests. – jonrsharpe Mar 22 '20 at 07:59
  • Also are you sure it's running all of the tests? I think it's just trying to compile your code before running the tests, if you fix the basic compilation errors does it run all of them? – jonrsharpe Mar 22 '20 at 08:00
  • can you give any example of --include command as referenced to login component? – ahsan Mar 22 '20 at 08:01
  • What is unclear from the docs? `--include path/to/login.component.ts`? – jonrsharpe Mar 22 '20 at 08:02
  • I tried `ng test --include ./src/app/modules/app-components/login.component.spe.ts` So it is giving an error like `specified pattern did not match any spec files` – ahsan Mar 22 '20 at 08:07
  • Typo - `.spe.ts`? – jonrsharpe Mar 22 '20 at 08:18
  • yes that's a typo. I tried with `spec.ts` – ahsan Mar 22 '20 at 08:19

0 Answers0