Sunday, 15 May 2011

javascript - Testing for instanceof using Jasmine -



javascript - Testing for instanceof using Jasmine -

i'm new jasmine , testing in general. 1 block of code checks whether library has been instantiated using new operator:

//if 'this' isn't instance of mylib... if (!(this instanceof mylib)) { //return new instance homecoming new mylib(); }

how can test using jasmine?

jasmine uses matchers assertions, can write own custom matcher check want, including instanceof check. https://github.com/pivotal/jasmine/wiki/matchers

in particular, check out writing new matchers section.

javascript unit-testing testing jasmine

No comments:

Post a Comment