How to remove all the spec files from existing Angular cli project
Asked Answered
F

4

9

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.

Fregger answered 28/3, 2019 at 13:39 Comment(1)
Any specific reason to remove spec file in application ?Cassation
A
18

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.

Animato answered 28/3, 2019 at 13:51 Comment(0)
S
0

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

Spessartite answered 12/4, 2023 at 7:39 Comment(0)
B
0

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

Brandenburg answered 28/12, 2023 at 9:52 Comment(0)
M
0

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

Monofilament answered 17/9, 2024 at 9:51 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.