javascript - Jasmine - Two spies for the same method -
i'm new jasmine
, wanted know if can create 2 spies same method. here i'm trying.
describe('something', function () { beforeeach(function () { myspy = jasmine.createspyobj('myspy', 'functionininterest'); myspy.functionininterest.andcallfake(function (cb) {cb(something);}); } //some test cases describe('here action!', function () { myspy = jasmine.createspyobj('myspy', 'functionininterest'); myspy.functionininterest.andcallfake(function (cb) {cb(somethingelse);}); //some test cases depends on somethingelse }); });
testcases before here action!
depend on myspy.functionininterest.andcallfake(function (cb) {cb(something);});
test cases inside here action!
depend on myspy.functionininterest.andcallfake(function (cb) {cb(somethingelse);});
note: both have same name
how can achieve this? in advance!
instead of
describe('here action!', function () { myspy = jasmine.createspyobj('myspy', 'functionininterest'); myspy.functionininterest.andcallfake(function (cb) {cb(somethingelse);}); //some test cases depends on somethingelse });
do this
describe('here action!', function () { myspy_2 = jasmine.createspyobj('myspy', 'functionininterest'); myspy_2.functionininterest.andcallfake(function (cb) {cb(somethingelse);}); //some test cases depends on somethingelse });
Comments
Post a Comment