Generate a .spec.ts file for Angular components

Discussão em 'Angular' iniciado por Lasen Punyawardana, Outubro 29, 2024.

  1. I have few components in my Angular project where the .spec.ts files were deleted. I tried creating a file through the IDE and renaming it to the same name as the component with .spec.ts as a suffix but the test cases written on that file are not run.

    How can I generate a test file for these components? The project is made in Angular 15.

    I tried creating a file manually through the IDE, I use WebStorm BTW. The test cases that were written in this file are never run when I use ng test --no-watch --code-coverage.

    I tried using the command ng g component component.name --spec-only but that said --spec-only is unknown on the terminal.

    Continue reading...

Compartilhe esta Página