-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Default reporter swallows console.log #392
Comments
I noticed this too. This is because of the animated reporting. Although, logging like that isn't very useful when you have more than one tests as the logging is synchronous while the test is not, so the logging could be outputted with a different test. I think a solution here is to handle the logging so that it's outputted with the correct test in verbose mode and with the default minimal reporter we could either show all logging at the end or during the testing by pushing the animated output down (meaning calling For now you can use the // @vdemedes |
That would be hard to do with console.log unless we either:
I think |
Yes, 3 is what I was thinking.
I think we should still log it with the mini reporter as it's still useful to quickly print out some values. |
@sindresorhus, @jamestalmage: We could also try hijacking/monkey-patching wither |
Yes, we could, but I have a feeling that comes with a lot of edge-cases, so we should first figure out |
Humble lurker here, so feel free to tell me I'm wrong -- Usually, when I find myself dropping in I've found debugging particularly tricky when experimenting with AVA since it also seems to give debuggers like node-inspector a hard time. In an ideal world, I'd love to see the log output for failed tests alongside the failed assertion or error. Successful tests could hide logs unless handed |
I think we should just hide the output from the mini reporter. I've encountered many TAP/mocha reporters, that just don't show console.log()s and that's it. With our animated beauty, there is simply no good way to display console.log() output.
Highly agree with @ecowden, I don't think anyone would use |
But how to debug? |
use |
Yeah, that was my concern as well. However, I think having a way to log output that you can be sure will be printed right underneath the ✅ of the related test is pretty valuable. Obviously At some point I think we need to start developing a "best practices / hints and tips / faq" document with stuff like this in it (where we fail to find ideal / straightforward solutions to these types of problems). For example, a good heading for the discussion we are having here would be "Debugging async tests", that talks about the difficulty of debugging async tests (it's hard to reason about console.log statements unless you enable |
@sindresorhus - for quickly printing out some values,
|
Usually I just console log in one place so I don't really need a context, but ok with using |
In that case the mini reporter should be fine. Though maybe we should somehow use hook-std or something to detect a line has been written and avoid deleting it. |
Yup, already suggested something like that initially, using logUpdate.done(). Would be nice. |
…vajs#392. This fixes two errors with our logging/io operations: 1. We were using the `stdio` option for `child_process.fork`, but that option is ignored (it is honored for just about every other method in that API). 2. The mini reporter uses logUpdate which deletes lines previously written with the logUpdate API before writing a new one. This caused problems if lines from console.log were written inbetween logUpdate calls. It would delete the users log messages instead of the last test title. To fix this, we store the last written logUpdate line, clear it, write the users log output, then restore the logUpdate line. This keeps the miniReporter output always at the bottom of the log output. Reference: - https://github.com/nodejs/node/blob/7b355c5bb30d7f9b38654fdb50e58dbd1dcd990a/lib/child_process.js#L49-L50
Not really. Patching For the first two, you could even Definitely not against Not sure what #415 does (haven't looked into it yet) but I figured I'd jump here and comment. Ava is a standalone application that has the special ability to be able to set up hooks in the environment to do what it does (it's a testing framework, after all). I'm surprised we don't hook more things (side effect testing and whatnot; |
This prevents interference between the mini logger and child processes that use `console.log`. The mini reporter previously used logUpdate which deletes lines previously written with the logUpdate API before writing a new one. This caused problems if lines from console.log were written inbetween logUpdate calls. It would delete the users log messages instead of the test status line. To fix this, we store the last written last log line, clear it, write the users log output, then restore the last log line. This keeps the miniReporter output always at the bottom of the log output. It also fixes an incorrect use of the `child_process` API. We were using the `stdio` option for `child_process.fork`, but that option is ignored (it is honored for just about every other method in that API). See: https://github.com/nodejs/node/blob/7b355c5bb30d7f9b38654fdb50e58dbd1dcd990a/lib/child_process.js#L49-L50 It also adds a set of visual tests which can be run via `npm run visual`. They must be run manually, and should be run as part of our pre-release process.
Fix some reporter / logging issues. Fixes #392
test.js
terminal output
Seems like the last string of logged text is swallowed.It complicate debuggin.
The text was updated successfully, but these errors were encountered: