Is there a way to get rid of the spec.ts file in Angularjs 2, whenever I create a new component. I know this is for testing purpose but what if I don't need it.
May be there is some setting to disable this specific testing file.
Is there a way to get rid of the spec.ts file in Angularjs 2, whenever I create a new component. I know this is for testing purpose but what if I don't need it.
May be there is some setting to disable this specific testing file.
Just adding this bit of information because I found myself struggling with the same issue and could not fix it by using the current answer(s), plus I did not want to make the changes on the
angular-cli.json
file. It appears the recent version of Angular CLI--spec=false
is depreciated and therefore no longer works, use--skipTests
instead.Test on:
Your command with then be:
ng g c mycomponent --skipTests
instead ofng g c mycomponent --spec=false
PS: Always test your commands using the
--dry-run
option to test your output.For angular 6+ Simply run this command:
OR
just add this in your angular.json file and you're good to go
NOTE: before pasting this check for conflicts, hope it helps
When using angular-cli there is a bunch of options to pass. To generate a new component without tests, you can simply add
--spec=false
like so:There is also an option in the angular-cli.json for which types you want to enable specs by default, where you can modify the behaviour:
You can use the following command when you create your component
In recent Angular versions you can configure the cli generator to disable the creation of spec file for components and services in
angular-cli.json
as follows:You can add extra lines to disable specs also for guards and classes and so on.