Generating Component without spec.ts file in Angular 2+

前端 未结 25 990
轮回少年
轮回少年 2021-02-01 00:48

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

25条回答
  •  一向
    一向 (楼主)
    2021-02-01 01:07

    When using angular-cli there is a bunch of options to pass. To generate a new component without tests, you can simply add --spec=false like so:

    ng generate component --spec=false my-component
    

    There is also an option in the angular-cli.json for which types you want to enable specs by default, where you can modify the behaviour:

    "defaults": {
      "spec": {
        "class": false,
        "component": true,
        "directive": true,
        "module": false,
        "pipe": true,
        "service": true
      }
    }
    

提交回复
热议问题