Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating Components without *.spec.ts in Angular 6

Tags:

angular6

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 
    },
    ...
}
like image 480
Chanuka Asanka Avatar asked May 05 '18 20:05

Chanuka Asanka


People also ask

Do we need Spec TS file in angular?

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.

What is -- Spec false in angular?

--spec false angular. ng g c without spec. "ng generate without test using angular" ng g module does not create spec files.

How to create a component without spec file in angular?

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": {} :

How to disable angular-CLI spec generation?

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.

How to skip tests when creating an angular component?

"@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.

How to generate a component without a'spec'file?

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.


1 Answers

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
    }
  }
like image 65
Chanuka Asanka Avatar answered Oct 09 '22 14:10

Chanuka Asanka