10

I am currently working with angular cli project. I see the spec file generated for every component, services and I want to remove all this spec files from this existing project.

1
  • Any specific reason to remove spec file in application ? Commented Mar 28, 2019 at 14:16

4 Answers 4

21

Deleting them from an existing project depends on your OS. If it is a Unix based system you could do something like this:

find . -type f -name '*.spec.ts' -delete

This would remove all files which end in spec.ts recursively starting in your current directory.

To prevent these files from being generated again use the --skipTests flag when generating components, providers, whatever:

ng g s my-service --skipTests

This will generate a service my-service without any spec files.

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

Comments

2

If your system is Windows, you can use this method

In PowerShell, navigate to your project directory.

For example cd C:\MyProject

Then enter this command

Get-ChildItem -Path src -Recurse -Filter *.spec.ts | Remove-Item

I used this method

Comments

0

For newer versions it's --skip-tests 👉🏻 ng generate

Comments

0

If you are on windows you can use this: del /s /q *.spec.ts

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.