javascript - Jasmine unit test failing? -
i've installed jasmine node module , set test function in test.js corresponding specs file testspec.js.
test.js:
var test = function () { var testfunction = function () { return 'test worked'; } return{ testfunction:testfunction } } module.exports = test(); testspec.js:
var test = require('../src/js/test'); describe("test function", function () { it("returns 'test worked'", function () { expect(test.testfunction().toequal('test worked')); }); }); when run test receive following error:
message: typeerror: test.testfunction(...).toequal not function stack: typeerror: test.testfunction(...).toequal not function hard-coding result 'test worked', receive no errors , test passes expected.
what missing?
parenthesis in wrong place expect - here go:
describe("test function", function () { it("returns 'test worked'", function () { expect(test.testfunction()).toequal('test worked'); }); }); edit: clarity - error received because chaining toequal off of function call rather encapsulating expect.
Comments
Post a Comment