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

Bring config.target into the light #2156

Closed
wants to merge 2 commits into from

Conversation

fatso83
Copy link
Contributor

@fatso83 fatso83 commented Nov 7, 2019

Purpose (TL;DR) - mandatory

Remove unneeded branch logic and improve docs.

Background (Problem in detail) - optional

When looking into a user question (#2155) it became obvious that the
it's not obvious at all that the docs for Lolex install config can be
used when trying to configure useFakeTimers.

For one, we added a prop, config.global, to Sinon's useFakeTimers config in #1935 that
was quite superfluous: it supported a use case that was already there using config.target!

In this PR, I remove some extra branching logic and also update the docs
to highlight the lolex docs and the target prop.

How to verify - mandatory

  1. npm test
  2. npm run build-docs

@fatso83 fatso83 added semver:major changes will cause a new major version and removed semver:major changes will cause a new major version labels Nov 20, 2019
@fatso83
Copy link
Contributor Author

fatso83 commented Nov 20, 2019

Basically fails due to sinonjs/fake-timers#276. One option I highlight there is to basically remove the target prop and just have one way of configuring Lolex for a different context. If so, I'd remove (or at least redo) these changes.

Updated docs: show link directly to lolex.install() docs to
simplify digging for the actual possible values.

Update test exception string
Copy link
Member

@mroderick mroderick left a comment

Choose a reason for hiding this comment

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

This looks good 👍

Needs a bit of love to get the tests passing.

Once this is in, I think we should put out the next semver:major with a good changelog update.

@fatso83
Copy link
Contributor Author

fatso83 commented Dec 5, 2019

@mroderick This kind of stalled because I don't know how to act around @SimenB's comment in Lolex, as this turned out to have a little catch: sinonjs/fake-timers#276 (comment): Is there a reason one might want to use the timers from a second environment and "pass them" into a third? That's basically the use case the current behavior supports that simplifying this in Lolex would remove.

@SimenB
Copy link
Member

SimenB commented Dec 5, 2019

FWIW, I don't think it's necessarily a valid use case. Maybe you want a working queueMicrotask into some other env that doesn't support it, but that's essentially polyfilling and not Lolex's responsibility at all

@stale
Copy link

stale bot commented Feb 3, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Feb 3, 2020
@mroderick mroderick removed the stale label Feb 4, 2020
@mroderick
Copy link
Member

@fatso83 @SimenB what do you think we should do with this PR?

@SimenB
Copy link
Member

SimenB commented Feb 4, 2020

I think that for now this can land as is, and if anything changes in lolex we can revisit. But the current implementation matches what's documented in this PR

fatso83 added a commit to fatso83/lolex that referenced this pull request Mar 23, 2020
Just use withGlobal(target) instead.
See sinonjs#276
for background and/or sinonjs/sinon#2156
@fatso83
Copy link
Contributor Author

fatso83 commented Mar 23, 2020

Sorry for keeping this hanging. Will redo once sinonjs/fake-timers#318 is merged.

@fatso83
Copy link
Contributor Author

fatso83 commented Mar 23, 2020

How would we like the API to look here? Keep the config.target (which is now proposed to be removed in the fake timers project) or expose withGlobal somehow? 😕

Might be worth considering that nise could also use such a thing.

fatso83 added a commit to fatso83/lolex that referenced this pull request Mar 25, 2020
@stale
Copy link

stale bot commented May 22, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 22, 2020
@mroderick mroderick added pinned and removed stale labels May 27, 2020
@mroderick
Copy link
Member

@fatso83 I think there's nothing left blocking this ... is there?

@fatso83 fatso83 closed this Jan 18, 2021
@fatso83
Copy link
Contributor Author

fatso83 commented Jan 18, 2021

As sinonjs/fake-timers#318 removed config.target (my doing), this PR no longer makes sense. What makes sense is document the global property introduced in #1935 and highlight that in our docs (missing) to avoid stuff like #2155 (comment).

@fatso83 fatso83 deleted the bring-target-into-the-light branch January 18, 2021 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants