Alternating Errors involving Spies, 2 out of 4 browsers always have errors.

15 views
Skip to first unread message

Blake VandeMerwe

unread,
Jun 7, 2012, 1:41:53 PM6/7/12
to Jasmine
With the following describe, I get errors in IE and Firefox that say
the spy has already been spied upon..

describe('checkAccelerators', function() {
var e = {
'shiftKey' : false,
'altKey' : true,
'ctrlKey' : true,
'which' : 0
}

beforeEach(function() {
spyOn(jasmine.getGlobal(), 'FunctionKeyF9');
});

it(' calls FunctionKeyF9 with F9 key.', function() {
with(e) {
e.which = 120;
checkAccelerators(e);
expect(FunctionKeyF9).toHaveBeenCalled();
}
});
});


....If I remove the beforeEach, it clears up the errors in Firefox and
IE, but throws errors in Chrome and Safari that say they expected a
spy but received a function.

Can you help me with this please? 3rd day in a row spies have given me
issues...is there some kind of "Further" documentation to read on
spies so I don't have to keep wasting everyone's time?

Davis W. Frank

unread,
Jun 7, 2012, 4:17:42 PM6/7/12
to jasmi...@googlegroups.com
If you're testing an event, you need to look at the async features - runs() and waits().

That said, I'd suggest testing your handlers without events, and then test your wiring of events, or use a browser framework.

--dwf


--
You received this message because you are subscribed to the Google Groups "Jasmine" group.
To post to this group, send email to jasmi...@googlegroups.com.
To unsubscribe from this group, send email to jasmine-js+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jasmine-js?hl=en.




--
thx,
--dwf

Reply all
Reply to author
Forward
0 new messages