In previous version, spec.ts can be disabled with .angular-cli.json as below. Is there any way to do it with angular.json in version 6.0.0?
"defaults": {
"component": {
"spec": false
},
"service": {
"spec": false
},
...
}
if you generate new angular project using "ng new", you may skip a generating of spec. ts files. For this you should apply --skip-tests option.
--spec false angular. ng g c without spec. "ng generate without test using angular" ng g module does not create spec files.
For Angular 8: ng generate component mycomponent --skipTests=false it will not generate spec.ts files. --spec will no longer work. Use --skip-tests instead. According to the fix #156 you can create a component without spec file by using For angular 6 add this in angular.json inside "schematics": {} :
You can also disable spec generation at the time of creating things using Angular-cli by adding "--no-spec" Method 2: Permanently disable in angular.json file. You can edit the schematics for your project. Show activity on this post. Easy way is you can use CLI as you used with previous versions. This will create the component without .spec file.
"@schematics/angular:service": { "skipTests": true }, "@schematics/angular:guard": { "skipTests": true } You can use the following command when you create your component Use also the following command if you want to skip your spec.ts file: g c => generate component , try-it => component name , --skipTest=true => == -- spec false.
to generate a component without a "...spec.ts" file you simply run "--spec false". Example below Sorry, something went wrong. Hi there!! Look at the default settings of component in schema.json (node_modules/@angular/cli/lib/config/schema.json) file.
in version "6.0.0" *.spec.ts can be disabled with angular.json
NOTE: don't forget to change the "prefix" property values "fmyp" and "fmp" to yours.
"schematics": {
"@schematics/angular:component": {
"prefix": "fmyp",
"styleext": "css",
"spec": false
},
"@schematics/angular:directive": {
"prefix": "fmp",
"spec": false
},
"@schematics/angular:module": {
"spec": false
},
"@schematics/angular:service": {
"spec": false
},
"@schematics/angular:pipe": {
"spec": false
},
"@schematics/angular:class": {
"spec": false
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With