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

fix bug when setTimeout is mocked #3769

Merged
merged 1 commit into from
Jun 9, 2017

Conversation

aaronabramov
Copy link
Contributor

tho things:

  1. Right now the whole circus thing is going on in the inner scope, meaning the globals like setTimeout are shared with the test and could be mocked (which will mess up circus internals). This is a quick fix to reference the real values before any test files are imported so nothing can mess with them. (i have a task to move circus to the outer scope, it'll take a while though, cause the code that does this right now is very complex)
  2. Sometimes tests won't return (exit) until all timeouts are resolved. To avoid this i save the timeout ids and clear them after the test is finished

@aaronabramov aaronabramov deleted the mocked-timeouts-1 branch June 8, 2017 17:59
@aaronabramov aaronabramov restored the mocked-timeouts-1 branch June 8, 2017 17:59
@aaronabramov aaronabramov reopened this Jun 8, 2017
@codecov-io
Copy link

Codecov Report

Merging #3769 into master will decrease coverage by 0.05%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #3769      +/-   ##
=========================================
- Coverage   59.86%   59.8%   -0.06%     
=========================================
  Files         191     191              
  Lines        7007    7014       +7     
  Branches        6       6              
=========================================
  Hits         4195    4195              
- Misses       2809    2816       +7     
  Partials        3       3
Impacted Files Coverage Δ
packages/jest-circus/src/utils.js 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 92e432a...fd873f2. Read the comment docs.

.then(() => {
// If timeout is not cleared/unrefed the node process won't exit until
// it's resolved.
timeoutID.unref && timeoutID.unref();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know that was a thing.

@cpojer cpojer merged commit 0d43300 into jestjs:master Jun 9, 2017
tushardhole pushed a commit to tushardhole/jest that referenced this pull request Aug 21, 2017
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants