Angular 9 CLI TypeScript - How to stop generating spec ts test files

0 votes

I'm using Angular-CLI, particularly ng g to generate all of my classes. However, I'm not interested in any *.spec.ts test files. I know that there are two flags (--inline-template, --inline-style) to handle inline CSS and HTML instead of separated files, and for spec the --spec flag is set to true by default.

So for each run, yes, I could do ng g c foo --it --is --spec=false.

But how do I disable the creation of test files globally? Is there any default setting for it?

Rashly, I did some stuff (that didn't work), like:

ng set spec=false --global

I also tried configuring my src/tsconfig.json by filling the exclude array:

"exclude": [
    "**/*.spec.ts"
]
Jun 13 in TypeSript by Logan
• 1,580 points
7 views

1 answer to this question.

0 votes

If you're using v6 and need to edit your angular.json

You can edit the schematics for your project.

"schematics": {
    "@schematics/angular:component": {
      "styleext": "scss",
      "spec": false
    },
    "@schematics/angular:class": {
      "spec": false
    },
    "@schematics/angular:directive": {
      "spec": false
    },
    "@schematics/angular:guard": {
      "spec": false
    },
    "@schematics/angular:module": {
      "spec": false
    },
    "@schematics/angular:pipe": {
      "spec": false
    },
    "@schematics/angular:service": {
      "spec": false
    }
  },
answered Jun 13 by Nina
• 2,900 points

Related Questions In TypeSript

0 votes
1 answer

How to create ES6 Map in Typescript

Refer this as an example this.configs = new ...READ MORE

answered May 31 in TypeSript by Nina
• 2,900 points
17 views
0 votes
1 answer

How to declare and initialize a Dictionary in Typescript

Apparently this doesn't work when passing the ...READ MORE

answered May 31 in TypeSript by Nina
• 2,900 points
50 views
0 votes
1 answer

How do you run TypeScript files from command line?

You can leave tsc running in watch mode using tsc ...READ MORE

answered May 31 in TypeSript by Nina
• 2,900 points
21 views
0 votes
1 answer

How to apply zoom animation for each element of a list in angular?

Hey @Sid, do check if this link ...READ MORE

answered Jul 30, 2019 in Others by Vardhan
• 13,200 points
476 views
0 votes
1 answer

could not find module "@angular-devkit/build-angular"

The mode must be changed to Dev ...READ MORE

answered Feb 8 in Java by Rahul
• 8,980 points
23 views
0 votes
1 answer

Can't bind to 'formGroup' since it isn't a known property of 'form'

In order to rectify this error, you ...READ MORE

answered Feb 10 in Others by Rahul
• 8,980 points
466 views
0 votes
1 answer

How to use moment.js library in angular 2 typescript app?

REFERENCE: https://momentjs.com/docs/#/use-it/typescript/ You can install this by using: npm install ...READ MORE

answered Jun 1 in TypeSript by Nina
• 2,900 points
17 views
0 votes
1 answer

How to get TypeScript definition files via bower?

The best option is to use tsd. It ...READ MORE

answered Jun 10 in TypeSript by Nina
• 2,900 points
11 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP