Get Component without spec.ts file in Angularjs 2

2020-05-20 05:21发布

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.

18条回答
兄弟一词,经得起流年.
2楼-- · 2020-05-20 05:40

For angular 6 add this in angular.json inside "schematics":{} :

"@schematics/angular": {
  "component": {
    "spec": false
  }
}

OR

as Franklin Pious sugested, run this command:

ng config schematics.@schematics/angular.component.spec false
查看更多
\"骚年 ilove
3楼-- · 2020-05-20 05:41

According to the fix #156 you can create a component without spec file by using

ng generate component my-comp --nospec
查看更多
我欲成王,谁敢阻挡
4楼-- · 2020-05-20 05:42

For Angular 6

ng config schematics.@schematics/angular.component.spec false
查看更多
孤傲高冷的网名
5楼-- · 2020-05-20 05:42

Simply create Component with this simple command in Angular 7

ng g c component-name --spec false

or if really dont want to include it in any component simply update angular.json

"@schematics/angular": {
  "component": {
    "spec": false
  }
}
查看更多
beautiful°
6楼-- · 2020-05-20 05:42

For Angular 8: ng generate component mycomponent --skipTests=false

查看更多
别忘想泡老子
7楼-- · 2020-05-20 05:44

For Angular 7 and higher this will work :

ng generate component componentname --skipTests

or ng generate component componentname --skipTests=true

查看更多
登录 后发表回答