user3564743
user3564743

Reputation: 71

Jasmine running on Grunt cant find async functions

For some reason the async functions (waits, waitsFor, runs) in Jasmine aren't available when I run it from Grunt.

In Grunt:

jasmine:{
    pivotal:{
        src: 'src/**/*.js',
        options:{
            specs: 'spec/**/*.spec.js'
        }
    }
}

In Jasmine spec:

describe('jasmine', function(){
    it("should find 'waits'", function(){
        waits(1000);
    });
    it("should find 'waitsFor'", function(){
        waitsFor(function(){}, 1000);
    });
    it("should find 'runs'", function(){
        runs(function(){});
    });
})

Jasmine output:

 jasmine
   × should find 'waits'
     ReferenceError: Can't find variable: waits in file:///G:/Projects/myproj/spec/test.spec.js (line 3) (1)
   × should find 'waitsFor'
     ReferenceError: Can't find variable: waitsFor in file:///G:/Projects/myproj/spec/test.spec.js (line 6) (1)
   × should find 'runs'
     ReferenceError: Can't find variable: runs in file:///G:/Projects/myproj/spec/test.spec.js (line 9) (1)

Am I missing something?

Upvotes: 2

Views: 2122

Answers (1)

user3564743
user3564743

Reputation: 71

turns out I'm used to using Jasmine 1.3, and the version used by grunt is 2.0. The syntax has changed in 2.0 and the tests need to be written according to the docs on http://jasmine.github.io/2.0/introduction.html

Upvotes: 5

Related Questions