Using qunit with a web application in an iframe

I am trying to use qUnit to do some unit testing, which requires running screens generated by my web application. My idea is to place my application in an iframe embedded in my qUnit test page. However, this does not seem to work (in chrome), I seem to be unable to access the iframe web application. If I do this in the chrome console, I get undefined:

frames ['MYAPP']. Document

I think this is due to some kind of cross-site scripting protection, but both my web application and my test page are served with localhost, so I don’t understand why this is happening, I also started Chrome with --disable -web-security, but this is not fixed.

Is there a better way to do unit testing that requires output from my application?

+5
source share
1 answer

You can try to publish these tests to localhost with any simple http server, for example, if you have a node, you can use https://github.com/nodeapps/http-server .

I have similar situational tests work in an iframe, and this work without problems.

+1
source

All Articles