Viewport is not defined in Karma DEBUG RUNNER
Tipster74743 opened this issue · comments
Test runs successfully and passes when running ng test in angular 4, but when debugging the tests through karma, viewport is undefined
For viewport to be defined and tests to pass in debug mode.
viewport is not being defined
Steps to reproduce the bug
- install karma-viewport using npm to an ng4 project
- add karma-viewport to karma.conf requirements
- add 'viewport' to karma frameworks array
- create a test and import viewport using 'declare const viewport'
- run test (success)
- click debug in karma window
- once successful tests will fail.
- Browser: Chrome
Hmm, well the debug window doesn't include the
iframe, so that's the main problem I guess. Probably
karma-viewport has to be extended so that it inserts an
iframe itself. I need to think about this a little but this is indeed a bug.
See #13. The solution is a little hacky, as I had to override the
debug.html injection logic and embed it into the standard
iframe context. However, it's the best possible solution as it has minimal impact for the way tests are structured and built and works interop with all other karma modules. I will issue a release within in a few hours when the build passes.
Yes sir, I will verify in just a moment.
This is what I'm getting now:
01 08 2017 14:14:00.184:ERROR [karma]: ReferenceError: query is not defined at fs.readFile (../node_modules/karma-viewport/dist/index.js:110:13) at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:504:3)
Did I miss something by chance?
That is really strange. Which Node version are you using?
My fault, there was a broken reference which the tests didn't catch. Please try 0.2.1 which was just released.
That fixed it, it is now working as intended. Thank you!
Thank you for the report! Feel free to provide feedback as this is a very young project.
Hi, suddenly I have this issue now with
"karma-viewport": "^1.0.4" ,
"karma": "^3.1.4", and
And it would only happen when I'm running a single spec in debug mode.