Search code examples
angularjsjasmineyeoman-generator

Skip tests in Angular project generated with Yo


I'm doing a small toy project to test Yeoman and angular.

After having created the application with yo angular I've started writing a service and its tests. Everything was perfect until I tried to ignore a test.

From what I've read I should be able to ignore a test changing it to xit and a suit changing describe to xdescribe.

But when I save and grunt launches the tests, I get a 'xit' is not defined or 'xdescribe' is not defined error.

Is there something I'm missing?


Solution

  • You will need to edit or maybe create a file called .jshintrc, and you will have something like this:

    {
        "curly": false,
        "eqeqeq": false,
        "immed": true,
        "latedef": true,
        "newcap": true,
        "noarg": true,
        "sub": true,
        "undef": true,
        "boss": true,
        "eqnull": true,
        "browser": true,
        "es5":true,
        "smarttabs": true,
        "expr":true,
        "globals": {
            "angular": true,
            "console": true,
            "expect" : true,
            "inject" : true,
            "describe" : true,
            "beforeEach" : true,
            "it" : true,
            "xit" : true,
            "xdescribe": true
        }
    }
    

    Notice the xit and xdescribe under globals.

    In your gruntfile go to jshint task and have this

     
    jshint: {
          options: {
            jshintrc: '.jshintrc'
          }
    }