I am use jasmine to do a unit test when write a javascript lib, I follow the official doc https://jasmine.github.io/tutorials/your_first_suite, the code demo.js look like this:
'use strict';
describe("A suite", function() {
it("contains spec with an expectation", function() {
expect(true).toBe(true);
});
});
when I am using this command to run the unit test:
istanbul cover _mocha ./test/demo.js
show the log output like this:
A suite
1) contains spec with an expectation
0 passing (6ms)
1 failing
1) A suite
contains spec with an expectation:
ReferenceError: expect is not defined
at Context.<anonymous> (test/demo.js:7:7)
what should I do avoid this problem? the node version is v10.24.1.The jasmine info:
I have tried to install jasmine-expect using this command:
npm install jasmine-expect --save-dev
still not fix it. Tried jasmine like this:
global.expect = require('jasmine-expect').expect;