Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component generation without spec file? #1256

Closed
duncanhunter opened this issue Jun 30, 2016 · 13 comments · Fixed by #1484
Closed

Component generation without spec file? #1256

duncanhunter opened this issue Jun 30, 2016 · 13 comments · Fixed by #1484
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@duncanhunter
Copy link

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.

  1. How do you use the generation feature of the CLI with out creating a spec file?
@kylecordes
Copy link

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.

@filipesilva filipesilva added type: enhancement P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent labels Jul 4, 2016
@jschwarty
Copy link
Contributor

Maybe an api like:

ng g c new-component --nospec

@Brocco Brocco self-assigned this Jul 28, 2016
Brocco added a commit to Brocco/angular-cli that referenced this issue Jul 28, 2016
Brocco added a commit to Brocco/angular-cli that referenced this issue Jul 28, 2016
Splaktar pushed a commit to DevIntent/angular-cli that referenced this issue Jul 31, 2016
@estrellajm
Copy link
Contributor

to generate a component without a "...spec.ts" file you simply run "--spec false". Example below

ng g c testfile --spec false

@Ranjita-M
Copy link

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
Copy link

hayat12 commented 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==false

@amitarora1991
Copy link

you can use -S with command to skip the test files

@agupadilla
Copy link

to generate a component without a "...spec.ts" file you simply run "--spec false". Example below

ng g c testfile --spec false

Option "spec" is deprecated: Use "skipTests" instead.

@aledroner
Copy link

Option "spec" is deprecated: Use "skipTests" instead. Example:
ng g s my-service --skipTests

@Yash-777
Copy link

Yash-777 commented Apr 3, 2019

application

ng generate application <name> [options]
OPTION DESCRIPTION
--skipTests=true|false When true, does not create "spec.ts" test files for the app.
Default: false
Aliases: -S

component

ng generate component <name> [options]
OPTION DESCRIPTION
--skipTests=true|false When true, does not create "spec.ts" test files for the new component/directive/class/guard.
Default: false
--spec=true|false Deprecated: Use "skipTests" instead.
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

angular-cli.json

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

@mmmichl
Copy link

mmmichl commented Apr 30, 2019

for consistency angular.json with angular cli 7:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  ...
  "projects": {
    "your-app": {
      ...
      "schematics": {
        "@schematics/angular:component": {
          "inlineStyle": false,
          "spec": false
        }
      },
....
}

@life347
Copy link

life347 commented May 9, 2019

@mmmichl Working Solution!

@ahadGitHub
Copy link

ng generate directive "directiveName" --skipTests

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.