Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Disable when inside tests #171

Closed
ehmicky opened this issue Nov 30, 2019 · 2 comments · Fixed by #173
Closed

Disable when inside tests #171

ehmicky opened this issue Nov 30, 2019 · 2 comments · Fixed by #173

Comments

@ehmicky
Copy link
Contributor

ehmicky commented Nov 30, 2019

When a binary is being tested, update-notifier should probably not be called since:

  • this would not work with snapshot testing, where the binary output is expected to match a specific string
  • this might make tests fail if update-notifier throws an error (e.g. if there is no network connection)
  • this makes tests slower
  • this adds no value (since only package maintainers run tests and do not need to be notified about new versions)

Now, knowing whether update-notifier is currently run inside a test might be tricky.

I think one naive approach which might cover some test runners would be to check for NODE_ENV. I.e. if process.env.NODE_ENV === 'test', disable update-notifier (like this is currently done with is-ci).

Note: I can provide with a PR.

What do you think?

@sindresorhus
Copy link
Member

I think one naive approach which might cover some test runners would be to check for NODE_ENV. I.e. if process.env.NODE_ENV === 'test', disable update-notifier (like this is currently done with is-ci).

👍 The behavior should be clearly documented though.

@ehmicky
Copy link
Contributor Author

ehmicky commented Dec 7, 2019

PR at #173.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants