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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -