-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
console.* functions called outside tests are not output when singleRun is false #3131
console.* functions called outside tests are not output when singleRun is false #3131
Comments
With your I guess this is an issue with karma-requirejs project or perhaps karma-jasmine. |
I've confirmed the issue when removing |
fwiw I'm having this same issue when using karma-mocha as well. console.logs outside of |
using a test file with:
and stepping through the karma versions, I've narrowed down this behavior change as occurring between v2.0.4 and v2.0.5. in 2.0.4:
in 2.0.5:
I'll try to compare those releases to see if I can narrow it down further. |
Narrowed it down to this commit: dc7265b which refactored the READY/CONNECTED state of the browser class. |
Tinkering in that commit, if I disable the
...then the logs outside of @johnjbarton can you tell me what purpose that check serves? My understanding is that it's ignoring logs generated during the 'configuring' state. That is, while the spec is being parsed, but before the tests actually start running, it's not emitting the |
Unfortunately The code you cite above, from Browser#onInfo, does not match what I see at HEAD: When I look at my own test case for global (pre-test) errors, I see events in browser.onKarmaError: The |
Ok I looked into this with our setup and I found that I needed to change Browse.onKarmaError: onKarmaError (error) {
if (this.isNotConnected()) {
this.lastResult.error = true
}
this.emitter.emit('browser_error', this, error)
this.refreshNoActivityTimeout()
} I also had to change our reporter to log the error in this case. We have a custom reporter. I will try to apply this change to karma-runner, but perhaps you can try it and see if it helps. |
I made a little POC repo https://github.com/pascalpp/karma-console-test and modified that part of lib/browser in place (after installing node_modules). I'm still not seeing the logs after that modification. |
Thanks, I tried the repo but
|
|
With
|
The |
Ok so the issue here is that with |
(oops sorry, forgot to include mocha in the deps, fixed now.)
Is that expected, or should it be browser.state == 2 in both cases? |
Under So we don't enter I don't see a reason to filter errors based on |
Expected behaviour
Using
client.captureConsole = true
, I expect allconsole.*
calls to output to the terminal.Actual behaviour
Only
console.*
calls occurring while running a test are output to the terminalEnvironment Details
karma --version
):3.0.0
karma.conf.js
:karma.test.js
:script.js
:Steps to reproduce the behaviour
karma.conf.js
,karma.test.js
,script.js
in a directorykarma start
to see actual behaviorkarma.conf.js
so thatsingleRun
istrue
to observe expected behaviorThe text was updated successfully, but these errors were encountered: