Search code examples
angulartypescriptionic4

schematics "spec": false not working on Ionic 4 app


How can I stop generating .spec file on Ionic 4 app?

I have tried this: But it is not working. i.e. still it generates .spec file.

ionic g service services/MyService

angular.json

  "schematics": {
    "@ionic/angular-toolkit:component": {
      "styleext": "scss"
    },
    "@ionic/angular-toolkit:page": {
      "styleext": "scss"
    },
    "@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
    }
  }
}

Solution

  • What is going on here is that default ionic boilerplate for Angular sets defaultCollection to @ionic/angular-toolkit:

    angular.json

    "cli": {
       "defaultCollection": "@ionic/angular-toolkit"
    },
    

    So you have to provide those flags for @ionic/angular-toolkit specific options like:

    "@ionic/angular-toolkit:service": {
      "spec": false, // or "skipTests": true
    }