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?
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.
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() .
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.
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' } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With