Skip to content
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

requiring lolex prints a warning #232

Closed
ehmicky opened this issue Feb 12, 2019 · 9 comments
Closed

requiring lolex prints a warning #232

ehmicky opened this issue Feb 12, 2019 · 9 comments

Comments

@ehmicky
Copy link

ehmicky commented Feb 12, 2019

require('lolex') prints the following warning:

(node:30019) ExperimentalWarning: queueMicrotask() is experimental.
  • Lolex version : 3.1.0
  • Environment : Node 11.9.0, Ubuntu 18.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 wrapping timers.queueMicrotask() so that global.queueMicrotask is only accessed when timers.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.

@benjamingr
Copy link
Member

@shdq

@shdq
Copy link
Contributor

shdq commented Feb 13, 2019

I'll take a look at this.

@benjamingr
Copy link
Member

@shdq thanks, a quick fix would be not to shim enqueueMicrotask by default.

@ehmicky
Copy link
Author

ehmicky commented Feb 13, 2019

Also for the detection: instead of typeof global.queueMicrotask === 'function' (which prints a warning), something like global.hasOwnProperty('queueMicrotask') does not print a warning.

@SimenB
Copy link
Member

SimenB commented Feb 13, 2019

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?

@benjamingr
Copy link
Member

benjamingr commented Feb 13, 2019

Good idea @SimenB , this is the second time I can recall it's breaking stuff.

@abrenneke
Copy link

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.

@ehmicky
Copy link
Author

ehmicky commented Mar 5, 2019

@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' 
      }
    } 
  }
})

@ehmicky
Copy link
Author

ehmicky commented Apr 13, 2019

Fixed by #233.

franck-romano pushed a commit to franck-romano/sinon that referenced this issue Oct 1, 2019
Removes the queueMicrotask() warning if you don't use it.

refs sinonjs#1985
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants