Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 692
Federico Nafria Avatar asked Jan 25 '14 21:01

Federico Nafria


People also ask

How do you skip the NG test?

Based on requirement, the user can skip a complete test without executing it at all or skip a test based on a specific condition. If the condition meets at the time of execution, it skips the remaining code in the test. Use the parameter enabled=false at @Test. By default, this parameter is set as True.

How do you skip the Jasmine test?

Excluding Tests / Specs If you want to exclude a specific test, simply use xit() instead of it() . The x means exclude. describe('description', function () { xit('description', function () {}); }); If you want to exclude an entire describe block, use xdescribe() instead of describe() .

What is beforeEach in Angular?

beforeEach is a global function in Jasmine that runs some setup code before each spec in the test suite. In this test suite, beforeEach is used to create a testing module using the TestBed object and declares any components that would be used in this testing module.


1 Answers

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'
      }
}
like image 184
TestersGonnaTest Avatar answered Nov 15 '22 05:11

TestersGonnaTest