I was creating the Angular component with --spec=false but now I need to do unit test, is there a way to create only spec.ts files with Angular CLI?
-
1dont think you have special command for this, but it very easy to add such file manuallyhappyZZR1400– happyZZR14002018-02-05 11:54:12 +00:00Commented Feb 5, 2018 at 11:54
-
Yes I can do it manually, but I want to know if there is a command for this... =Ddeleting– deleting2018-02-05 11:55:30 +00:00Commented Feb 5, 2018 at 11:55
-
Possible duplicate of Angular CLI create .spec files for already existing componentsArtem S.– Artem S.2018-08-01 19:50:10 +00:00Commented Aug 1, 2018 at 19:50
Add a comment
|
2 Answers
Currently, Angular CLI does not provide this functionality. However, you can make a pull request to the @angular/cli team to integrate your idea, and if the code works and the idea seems good enough, they might add it.
Or, you can use SimonTest is an extension to VS Code that generates tests for existing files.
2 Comments
William Hou
Yes. SimonTest is the app for creating a spec.ts file within an existing component folder.
rob
Tried a number of alternative spec creators and SimonTest was the only one that took an existing Component and generated a functional spec file with all the required imports, declarations, providers etc
According to this Feature Request, it has not been implemented at this time. I think you have to do it by hand for now.