You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an app that runs in <iframe> is tested, toThrowError reports incorrectly. It says "Expected function to throw an Error, but it threw...".
Jasmine uses Error constructor in current window, but it was made by Error constructor in child window.
describe('App running in <iframe>',function(){functionmethodC(){thrownewError('baz');}varchildWindow;beforeAll(function(done){// Prepare <iframe>variframe=document.body.insertBefore(document.createElement('iframe'),document.body.firstChild)iframe.addEventListener('load',function(){childWindow=iframe.contentWindow;// self.Error = childWindow.Error;done();});iframe.src='app.html';});it('should return foo',function(){expect(childWindow.methodA()).toBe('foo');});it('should throw an error',function(){expect(function(){childWindow.methodB();}).toThrowError('bar');});it('(test in current window)',function(){expect(function(){methodC();}).toThrowError('baz');});});
Hi, thank you for the great framework.
When an app that runs in
<iframe>
is tested,toThrowError
reports incorrectly. It says "Expected function to throw an Error, but it threw...".Jasmine uses
Error
constructor in current window, but it was made byError
constructor in child window.In this code:
jasmine/src/core/matchers/toThrowError.js
Line 31 in 8624a52
It checks with the
Error
in current window always. But thethrown
was made in differentglobal
(namespace).For example:
app.html
The second spec fails.
I think, this line:
should be:
This gets
Error
from the sameglobal
asthrown
.The text was updated successfully, but these errors were encountered: