4

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?

3
  • 1
    dont think you have special command for this, but it very easy to add such file manually Commented Feb 5, 2018 at 11:54
  • Yes I can do it manually, but I want to know if there is a command for this... =D Commented Feb 5, 2018 at 11:55
  • Possible duplicate of Angular CLI create .spec files for already existing components Commented Aug 1, 2018 at 19:50

2 Answers 2

6

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Yes. SimonTest is the app for creating a spec.ts file within an existing component folder.
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
2

According to this Feature Request, it has not been implemented at this time. I think you have to do it by hand for now.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.