Pergunta

I'm trying to write some JavaScript unit tests using jasmine-node and jquery-jasmine, and I'm stuck with a configuration problem. Currently, here is the only "test" I"m trying to run:

describe("A suite", function() {
    it("contains spec with an expectation", function() {
        loadFixtures('blah.html');
        expect(true).toBe(true);
    });
});

I'm getting the following error when I try to run the test:

    Failures:

      1) A suite contains spec with an expectation
       Message:
         ReferenceError: loadFixtures is not defined
       Stacktrace:
         ReferenceError: loadFixtures is not defined
        at [object Object].<anonymous> (/home/chris/Source/www/projects/wash/spec/javascripts/blah.spec.js:6:9)
        at [object Object].execute (/usr/local/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1001:15)
        at [object Object].next_ (/usr/local/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1790:31)
        at [object Object].start (/usr/local/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1743:8)
        at [object Object].execute (/usr/local/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:2070:14)
        at [object Object].next_ (/usr/local/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1790:31)
        at [object Object].start (/usr/local/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1743:8)
        at [object Object].execute (/usr/local/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:2215:14)
        at [object Object].next_ (/usr/local/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1790:31)
        at [object Object].start (/usr/local/lib/node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js:1743:8)

Finished in 0.006 seconds
1 test, 1 assertion, 1 failure

When I comment out the loadFixtures line in the test, it works fine.

I assume that jasmine-jquery is not loading properly, but I'm not sure what to do about that. (I have very little experience with nodejs or npm.)

If it's of diagnostic value, when I run which jasmine-node (within bash) I get a result, but when I run which jasmine-jquery, I do not. I assume that this is because the former is meant to be executable while the latter is not, but I don't want to make any assumptions. (npm show indicates that both packages are installed, however.)

What am I doing wrong?

Thanks very much for your help.

Foi útil?

Solução

you probably just need to require it before using it ;-)

var $ = require("jasmine-jquery");
describe("A suite", function() { ...
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top