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, 2022 in TypeSript by Logan
• 2,140 points
3,442 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
    }
  },

To know more about Angular, It's recommended to join Angular Online Course today.

answered Jun 13, 2022 by Nina
• 3,060 points

Related Questions In TypeSript

0 votes
0 answers
0 votes
1 answer

How to create ES6 Map in Typescript

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

answered May 31, 2022 in TypeSript by Nina
• 3,060 points
871 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, 2022 in TypeSript by Nina
• 3,060 points
6,538 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,150 points
1,589 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, 2022 in Java by Rahul
• 9,680 points
7,097 views
0 votes
1 answer
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, 2022 in Others by Rahul
• 9,680 points
21,394 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, 2022 in TypeSript by Nina
• 3,060 points
1,692 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, 2022 in TypeSript by Nina
• 3,060 points
596 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP