Closed ehmicky closed 5 years ago
@shdq
I'll take a look at this.
@shdq thanks, a quick fix would be not to shim enqueueMicrotask
by default.
Also for the detection: instead of typeof global.queueMicrotask === 'function'
(which prints a warning), something like global.hasOwnProperty('queueMicrotask')
does not print a warning.
In general, should updating the default shimmed functions be considered a breaking change? So don't shim new stuff by default, then for new majors activate everything?
Good idea @SimenB , this is the second time I can recall it's breaking stuff.
Some console things, for example ava's default reporter, start to break a little if there are any console logs or warnings during operation, and because each ava node process ends up logging a new warning, the output gets rather messy because of this issue. I've turned off node warnings with NODE_NO_WARNINGS=1
, but obviously I'd like to turn those back on.
@SneakyMax A pending PR #233 exists. Until this PR is merged, if you want to only hide the warning printed by Lolex, you can use log-process-errors
to remove this warning during Ava tests:
// Those two lines must be run before `require('lolex')` is first called
const logProcessErrors = require('log-process-errors')
logProcessErrors({
level: {
warning({ message }) {
if (message.includes('queueMicrotask() is experimental')) {
return 'silent'
}
}
}
})
Fixed by #233.
require('lolex')
prints the following warning:3.1.0
11.9.0
, Ubuntu18.10
What did you expect to happen? There should be no warnings printed on the console when
queueMicrotask()
is not used by the calling code. This could for example be done by wrappingtimers.queueMicrotask()
so thatglobal.queueMicrotask
is only accessed whentimers.queueMicrotask()
is called.Experimental warnings can be turned off with
--no-warnings
but this is inconvenient as it removes other potentially useful warnings.Why suppressing this warning matters: some users (like me) might have precise expectations on what's printed on the console, if console output is being parsed, for example for logging purpose. Also some users might see this warning and without additional context think it was triggered from their code, making them debug a non-issue.
What actually happens There is a warning printed on console.
How to reproduce See above.