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条回答
Bombasti
2楼-- · 2020-05-20 05:54

simply try this one. this is working

ng g c component_name --spec false
查看更多
一夜七次
3楼-- · 2020-05-20 05:54

For Angular 9 you can use

ng g c "componentName" --spec=false

to generate component without spec file

查看更多
混吃等死
4楼-- · 2020-05-20 05:55

Updated for angular 8 CLI

ng generate component --skipTests=true component-name

Inside your angular-cli.json set the spec.component parameter to false:

{
   ...
   "defaults" : {
       ...
       "spec": {
           ...
           "component": false
       }
   }
}

or use the --spec=false option during creation

ng generate component --spec=false component-name
查看更多
ゆ 、 Hurt°
5楼-- · 2020-05-20 06:01

There is a command for disabling Angular generate "spec" files by default

ng set defaults.class.spec=false
ng set defaults.component.spec=false

UPDATE: For Angular 6

ng config schematics.@schematics/angular.component.spec false

查看更多
迷人小祖宗
6楼-- · 2020-05-20 06:03

Use also the following command if you want to skip your spec.ts file:

ng g c try-it --skipTests=true

where

g c => generate component , try-it => component name , --skipTest=true => == -- spec false.

查看更多
放荡不羁爱自由
7楼-- · 2020-05-20 06:04

here what it is for angular 9

ng g class models\user --skip-tests true

it will not generate spec.ts files.

查看更多
登录 后发表回答