You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Frequently we make components with no logic that we do not wish to write unit tests for. We would like to use the CLI to generate components with no spec file.
How do you use the generation feature of the CLI with out creating a spec file?
Reacted by Justin Schwartzenberger, r4bbit, Shramee Srivastav, Gus, minmhan, Mitja O., Anastasiia Wolfertz, Hernan B, Amine Harbaoui, Jamie Perkins and 4 more
I think this is especially relevant for projects that follow the "smart component vs visual component" pattern. The purely visual components in such a design usually should not have anything in them worthy of a test.
to generate a component without a "...spec.ts" file you simply run "--spec false". Example below
ng g c testfile --spec false
Reacted by Gremn, pareshvarde, Alexandre Percebois, Andrei Constantin, Ojong Eric Obasi, Kodjo Novinyo AMEGADJE, Ramon William, Glauco Godoi, MEARAJ BHAGAD, Roger Hand and 45 more
Hi there!!
Look at the default settings of component in schema.json(node_modules/@angular/cli/lib/config/schema.json) file. Change as required..
If you don't want to generate spec file, just make default property value to false..
"component":
{
"properties":
{
"spec":
{
"description": "Specifies if a spec file is generated.",
"type": "boolean",
"default": true
}
}
}
Hello, @duncanhunter i am advancing you to create the component manually, mostly when we use cli we don't know what is the use of the generated files. and in case if you want to generate the component with cli without spec you can use this ng g component list --spec==false
Reacted by shahid ahmad, Nicolae Olariu, userofit, Christian Knoll and miguelplazas
Activity
kylecordes commentedon Jun 30, 2016
I think this is especially relevant for projects that follow the "smart component vs visual component" pattern. The purely visual components in such a design usually should not have anything in them worthy of a test.
jschwarty commentedon Jul 28, 2016
Maybe an api like:
ng g c new-component --nospecfeat(tests): allow to create component without a spec file
feat(tests): allow to create component without a spec file
feat(tests): allow to create component without a spec file
estrellajm commentedon Nov 19, 2017
to generate a component without a "...spec.ts" file you simply run "--spec false". Example below
ng g c testfile --spec false
Ranjita-M commentedon May 15, 2018
Hi there!!
Look at the default settings of component in schema.json(node_modules/@angular/cli/lib/config/schema.json) file. Change as required..
If you don't want to generate spec file, just make default property value to false..
"component":
{
"properties":
{
"spec":
{
"description": "Specifies if a spec file is generated.",
"type": "boolean",
"default": true
}
}
}
hayat12 commentedon May 17, 2018
Hello, @duncanhunter i am advancing you to create the component manually, mostly when we use cli we don't know what is the use of the generated files. and in case if you want to generate the component with cli without spec you can use this
ng g component list --spec==falseamitarora1991 commentedon Jul 1, 2018
you can use -S with command to skip the test files
agupadilla commentedon Feb 27, 2019
Option "spec" is deprecated: Use "skipTests" instead.
aledroner commentedon Mar 1, 2019
Option "spec" is deprecated: Use "skipTests" instead. Example:
ng g s my-service --skipTestsYash-777 commentedon Apr 3, 2019
application
Default: false
Aliases: -S
component
component/directive/class/guard.Default: false
When true (the default), generates a "spec.ts" test file for the new component.
Default: true
Angular 2:
angular-cli.json
mmmichl commentedon Apr 30, 2019
for consistency
angular.jsonwith angular cli 7:{ "$schema": "./node_modules/@angular/cli/lib/config/schema.json", ... "projects": { "your-app": { ... "schematics": { "@schematics/angular:component": { "inlineStyle": false, "spec": false } }, .... }life347 commentedon May 9, 2019
@mmmichl Working Solution!
ahadGitHub commentedon Jul 16, 2019
ng generate directive "directiveName" --skipTests
angular-automatic-lock-bot commentedon Sep 9, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.