Get Component without spec.ts file in Angularjs 2
- saadeez
- 2016-12-06 07:47
- 9
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.
9 Answers
For Angular 6
ng config schematics.@schematics/angular.component.spec false
angular-cli generate component without spec and css, Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Learn more Angular / create a module, component without css file in one command? When true, runs through and reports activity without writing out results. Default: css When true, does not create "spec.ts" test files for the new component.
Franklin Pious
2018-06-23 12:09
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
}
}
angular-cli generate component without css, Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Learn more Angular / create a module, component without css file in one command? The cli creates a single . ts file in the current folder and links it in the module. You can use ng generate -is for inline-style , which will not generate css file separately, but will keep css inside component (inline).
Andreas Jägle
2016-12-06 07:57
For angular 6+ Simply run this command:
ng config schematics.@schematics/angular.component.spec false
OR
just add this in your angular.json file and you're good to go
"schematics": {
"@schematics/angular": {
"component": {
"spec": false
}
}
}
NOTE: before pasting this check for conflicts, hope it helps
ng gc component'': ( spec false), yes exactly when we generate component from Angular cli. – saadeez Dec 6 '16 at 7:56. 1. ng g c component-name --spec false You can find these options using ng g c --help – JB Nizet Dec 6 '16 at 7:58. 2. ng generate component --spec=false component-name simply try this one. this is working ng g c component_name --spec false.
Zub
2019-02-15 22:04
In recent Angular versions you can configure the cli generator to disable the creation of spec file for components and services in angular-cli.json as follows:
"defaults": {
"component": { "spec": false },
"service": { "spec": false },
...
}
You can add extra lines to disable specs also for guards and classes and so on.
option "spec" is deprecated: use "skiptests" instead., Option "spec" is deprecated: Use "skipTests" instead. Deprecated: Use "skipTests" instead. When true (the default), generates a "spec.ts" test file for the new We would like to use the CLI to generate components with no spec file. How do you use Option "spec" is deprecated: Use "skipTests" instead.
moeabdol
2017-12-10 20:39
simply try this one. this is working
ng g c component_name --spec false
ng generate component path, ng generate component component-name After he runs it, the tool generates the files inside the current directory, but when I try the same, the tool ends up generating the files at the app root folder. Route path used to produce the app shell. Default: ng generate component < name > [ options ] The prefix to apply to the generated component selector.
Ragulan
2018-05-02 14:10
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
angular-cli spec'': false, So for each run, yes, I can do so ng g c foo --it --is --spec=false. But How to disable the creation of test files globally? is there any default setting for it? Rashly, I did some stuff like (that didn't work): ng set spec=false --global. Then tried configuring ts settings file src/tsconfig.json by filling the exclude array. When true, does not create "spec.ts" test files for the app. Default: false. Aliases: -S. --style= css|scss|sass|less
Ahmed Essawy
2018-09-28 14:31
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
}
}
ng generate routing module, Angular is a platform for building mobile and desktop web applications. Join the community of millions of developers who build compelling user interfaces with Angular. One framework. rootModuleFileName. The name of the root module file. Default: app.server.module.ts. --route= route. Route path used to produce the app shell. Default: shell.
Ian Samz
2018-11-27 13:38
ng g c component-name --spec false
unknown option: '--spec', Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question.Provide details and share your research! But avoid …. Asking for help, clarification, or responding to other answers. spec.ts (986 bytes) create project/src/app/app.component.ts (207 bytes) error: unknown option `--silent' Error:
Anand Mohan
2017-06-14 03:28

Updated for angular 8 CLI
Inside your
angular-cli.jsonset the spec.component parameter tofalse:{ ... "defaults" : { ... "spec": { ... "component": false } } }or use the
--spec=falseoption during creationComponent generation without spec file? · Issue #1256 · angular , Updated for angular 8 CLI ng generate component --skipTests=true component-name. Inside your angular-cli.json set the spec.component When true (the default), generates a "spec.ts" test file for the new component. Default: true. Angular 2: ng g c component-name --spec false.
PierreDuc
2019-08-20 09:52