Is there a way to get rid of the spec.ts file in Angular 2+, whenever I create a new component. I know this is for testing purpose but what if I don\'t need it.
May be t
ng generate component your-component-name --skipTests=true
or using the alias s
instead of --skipTests
ng generate component your-component-name -s=true
angular.json
to avoid using above CLI command alwaysCopy the below snippet to the root of a specific project (projects.your-project-name
) in its angular.json
.
The below will ensure .spec
files are not created for Components, Class, Directives, Pipe and Service with the ng generate
command. You may choose the ones as per requirement.
{
...
"projects": {
"your-project-name": {
...
"schematics": {
"@schematics/angular:component": {
"style": "scss",
"skipTests": true
},
"@schematics/angular:class": {
"skipTests": true
},
"@schematics/angular:directive": {
"skipTests": true
},
"@schematics/angular:pipe": {
"skipTests": true
},
"@schematics/angular:service": {
"skipTests": true
}
},
...
}
PS: The --spec=false
option is now deprecated and will not work