Skip tests in Angular project generated with Yo
Asked Answered
Y

1

6

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?

Yolande answered 25/1, 2014 at 21:27 Comment(7)
open Gruntfile.js at the end locate grunt.registerTask('default', [ 'newer:jshint', 'test', 'build' ]); remove the test line, when you need to test use grunt testOutofdate
After changing what you suggested, it keeps failing, but, anyway, I don't want to disable ´jshint´.Yolande
I'm having the same issue. Even after adding xdescribe and xit to the .jshintrc file it still thrown an error. My project is also an angular-generator app.Wellpreserved
@mrjedmao Did you modify the test/.jshintrc? I ask because there is another .jshintrc at the root of the application.Yolande
@Federico Nafria, yes, I did.Wellpreserved
I did exactly what TestersGonnaTest suggested in his answer and its working now. I did not modify the GruntFile. @mrjedmaoYolande
@FedericoNafria, well it's working now, so I must have done it wrong the first time. Thanks!Wellpreserved
U
4

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'
      }
}
Ultraism answered 27/1, 2014 at 14:48 Comment(3)
Could this be a bug in the app generation?Yolande
I don't really understand your question. From jshint docs: JSHint comes with a default set of warnings but it was designed to be very configurable. There are three main ways to configure your copy of JSHint: you can either specify the configuration file manually via the --config flag, use a special file .jshintrc or put your config into your projects package.json file under the jshintConfig property.Ultraism
Yes, I understand that is possible to configure jsHint, but it seems weird that Yeoman is generating the app without the possibility to ignore tests.Yolande

© 2022 - 2024 — McMap. All rights reserved.