-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
window.require
does not work; you must use window.parent.require
#27
Comments
@suchipi Hi :) Thanks for your report! But I can not reproduce it, in my env... https://github.com/bokuweb/karma-nightmare/blob/master/test/index.spec.js#L10 If test fixture has https://github.com/bokuweb/karma-nightmare/blob/master/lib/browser.js#L38 |
I will try to put together a repro repo you can clone. I'm using it in a pretty involved setup so it might be related to my karma config. |
@suchipi It is very helpful. Did you customize your |
No, but I have tracked down the issue and it is related to that. |
It looks like the code evaluated by nightmare can run in either the top-level context or the iframe context, so I think this line: const iframe = (window.parent ? window.parent.document : document).querySelector('iframe#context'); |
@suchipi I see. Thanks for your great investigation :) I'll fix it so. |
Thank you! |
@suchipi 0.4.15 published 🎉 Could you please try it, if you get a chance? |
I have tried it but it does not fix the issue. To test:
I misunderstood when I'm not sure how to fix it. |
Hmmm, sorry, I'll do the investigation. |
It looks like the preload script only runs the first time you load the window, not on subsequent refreshes; I think that's the issue here. I am using this workaround in my code: |
I see. understood. But I have not found a nice way to solve this problem yet. |
Overview of the problem
I'm using karma-nightmare version [0.4.14]
I am sure this issue is not a duplicate.
Description
The readme indicates that
window.require
is available, but because the code runs in an iframe,window.parent.require
must be used.Steps to Reproduce
Run the following in a test with karma and karma-nightmare:
Expected behavior
Outputs
function require(path) { ... }
Actual behavior
Outputs
undefined
Workaround
Outputs
function require(path) { ... }
The text was updated successfully, but these errors were encountered: