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

Issue #1852: Add a way to pass a global context to lolex when calling useFakeTimers #1935

Merged
merged 1 commit into from Oct 25, 2018

Conversation

LouisBrunner
Copy link
Contributor

Purpose (TL;DR)

Partial fix of issue #1852: Add a way to pass a global context to lolex when calling useFakeTimers

Background

As discussed in #1852, some environments make sinon.useFakeTimers crash, because of lolex, when some properties are missing in the global object. The issue has been improved by triggering a more explicit error in lolex, however this PR adds a way to provide the global context directly and forward it to lolex.

Solution

This PR adds an extra property when using sinon.useFakeTimers with an object argument: by giving the global property, lolex.withGlobal(global) will be called and used to install the clock instead of using the default implementation.

How to verify

Checkout this repositoy for an example of an environment that triggers this bug.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 2727

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 94.881%

Totals Coverage Status
Change from base Build 2726: 0.02%
Covered Lines: 2065
Relevant Lines: 2137

💛 - Coveralls

Copy link
Contributor

@fatso83 fatso83 left a comment

Choose a reason for hiding this comment

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

Looks great!

@mroderick mroderick merged commit 60fb06e into sinonjs:master Oct 25, 2018
@mroderick
Copy link
Member

This has been published as sinon@7.1.0. Thank you :)

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

Successfully merging this pull request may close these issues.

None yet

4 participants