How to disable *.spec.ts files generation when i generate components/services from console, like this ng g component page1
I use Angular CLI 1.0.0
Seems related to https://github.com/angular/angular-cli/pull/6064 and https://github.com/angular/angular-cli/issues/6054 .. I used to think --skip-tests
would not generate any any .spec.ts
files like on beta. However, based on the comments of https://github.com/angular/angular-cli/issues/6054, it seems on 1.0.0 the intended behavior for --skip-tests
was only to not generate the initial test file generated with the app component.
@dave11mj, But what should i do if i already have created a project ?
--skip-tests
- doesn't work
You can disable file generation through your angular-cli.json.
See: schema.json and search for defaults. Each generate command has it's own config.
Closing as above.
@grizzm0 how i can do it in angular-cli.json ? (for example component)
Just read the schema file. Set defaults.component.spec to false.
There's lots of stuff you can change. See: https://github.com/angular/angular-cli/blob/398356503ab4729cf40587804c44b55eb5c99768/packages/%40angular/cli/lib/config/schema.json#L318-L353
Hi, @grizzm0
I tried to globally disable generation of spec and css file(in .angular-cli.json) when I generate new component. However it doesn't work, files are still created.
I use Angular CLI 1.4.2
Here's my .angular-cli.json:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "angular5"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.css"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json"
},
{
"project": "src/tsconfig.spec.json"
},
{
"project": "e2e/tsconfig.e2e.json"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"component": {
"properties": {
"spec": {
"default": false
},
"inlineStyle": {
"default": true
}
}
}
}
}
@it-discovery Besides, you do write this on command line ng g c component-name --spec false
@it-discovery it should be like this
{
"defaults": {
"component": {
"spec": false
}
}
}
For Angular 6
ng config schematics.@schematics/angular.component.spec false
I confirm that this is the way to do it in Angular 6
@alfmoh it worked for me.
But, for module and service I had to put this extra configuration on my angular.json:
"schematics": {
"@schematics/angular": {
"component": {
"spec": false
},
"module": {
"spec": false
},
"service": {
"spec": false
}
}
}
You can run this command to disable spec file generation for a specific type of file:
ng set defaults.spec.FILETYPE false
For example:
ng set defaults.spec.component false // Won't generate spec files for .component files
Alternately you can just disable all spec file generation from the angular.json file.
{
...
"defaults": {
"spec": {
"class": false,
"component": false,
"directive": false,
"module": false,
"pipe": false,
"service": false
}
}
}
@sammirzagharcheh Isn't ng set deprecated in favor of ng config?
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
@it-discovery it should be like this