Karma: The console of iframes is not printed on the command line

Created on 14 Apr 2015  路  2Comments  路  Source: karma-runner/karma

Here is a small test that illustrates the problem.

This is the output of the command line:

WARN [karma]: Port 9876 in use
INFO [karma]: Karma v0.12.31 server started at http://localhost:9877/
INFO [launcher]: Starting browser Safari
INFO [launcher]: Starting browser Firefox
INFO [launcher]: Starting browser Chrome
INFO [Firefox 37.0.0 (Mac OS X 10.10)]: Connected on socket bYlZenP4N4gvK5rj1a4D with id 14819077
INFO [Safari 8.0.5 (Mac OS X 10.10.3)]: Connected on socket KVxHjtic4VMkKl171a4C with id 69586727
INFO [Chrome 41.0.2272 (Mac OS X 10.10.3)]: Connected on socket JUOIFWPM4P3o8Kuh1a4E with id 29479825
Firefox 37.0.0 (Mac OS X 10.10) LOG: 'Create iframe'
Chrome 41.0.2272 (Mac OS X 10.10.3) LOG: 'DOMContentLoaded'
Chrome 41.0.2272 (Mac OS X 10.10.3) LOG: 'init'
Chrome 41.0.2272 (Mac OS X 10.10.3) LOG: 'Create iframe'
Firefox 37.0.0 (Mac OS X 10.10) LOG: 'test dynamically loaded iframe'
Chrome 41.0.2272 (Mac OS X 10.10.3) LOG: 'test dynamically loaded iframe'
Firefox 37.0.0 (Mac OS X 10.10) LOG: 'test to trigger event'
Chrome 41.0.2272 (Mac OS X 10.10.3) LOG: 'test to trigger event'
Safari 8.0.5 (Mac OS X 10.10.3) LOG: 'Create iframe'
Safari 8.0.5 (Mac OS X 10.10.3) LOG: 'test dynamically loaded iframe'
Safari 8.0.5 (Mac OS X 10.10.3) LOG: 'test to trigger event'
Safari 8.0.5 (Mac OS X 10.10.3): Executed 2 of 2 SUCCESS (4.887 secs / 1.997 secs)
Firefox 37.0.0 (Mac OS X 10.10): Executed 2 of 2 SUCCESS (0.222 secs / 0.21 secs)
Chrome 41.0.2272 (Mac OS X 10.10.3): Executed 2 of 2 SUCCESS (0.223 secs / 0.209 secs)
TOTAL: 6 SUCCESS

This is the console output of the debug tool:

"Create iframe" test.js:6:4
En iframe som har b氓de allow-scripts och allow-same-origin f枚r sitt sandbox-attribut kan ta bort sin sandboxning. debug.html
Teckenkodningen f枚r ett ramdokument var inte deklarerad. Dokumentet kan se annorlunda ut om det visas utan dokumentet som inneh枚ll ramen. frame.html
"DOMContentLoaded" frame.html:18:6
"init" frame.html:11:6
"test dynamically loaded iframe" test.js:20:6
"SUCCESS iframes and events: test dynamically loaded iframe" debug.html:35:0
"test to trigger event" test.js:34:6
"SUCCESS iframes and events: test to trigger event" debug.html:35:0
"init" frame.html:11:6
"CLICK EVENT" frame.html:13:8
"CLICK IN FRAME" frame.html:1:0
"Skipped 0 tests" debug.html:25:8

Perhaps not a major problem if you are aware of this. But I was quite confused until I understood the problem. It would be great if it's possible to fix. Thank's for a good testing tool!

Most helpful comment

@colmsjo Thanks!

But karma more tool to unit testing not for e2e testing.
In your case you can remap console from iframe like:

document.getElementById('frame').contentWindow.console = console;

this should fix problem

All 2 comments

@colmsjo Thanks!

But karma more tool to unit testing not for e2e testing.
In your case you can remap console from iframe like:

document.getElementById('frame').contentWindow.console = console;

this should fix problem

Yes, that fixed it! Thank's.

Was this page helpful?
0 / 5 - 0 ratings