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

Stop using Lolex, since we're using Jest's "modern" fake timers. #4931

Merged
merged 8 commits into from
Aug 11, 2021

Conversation

chrisbobbe
Copy link
Contributor

Planned followup to #4754.

@chrisbobbe chrisbobbe added the dependencies Pull requests that update a dependency file label Jul 30, 2021
@chrisbobbe chrisbobbe requested review from gnprice and WesleyAC July 30, 2021 18:02
Use Jest's "modern" fake timers instead of our Lolex wrapper.

Also, remove one `describe` block for tests that examine an
edge-case safety feature that we built into our Lolex wrapper, but
that doesn't seem to exist in Jest. Ah, well.
Use Jest's "modern" fake timers instead of our Lolex wrapper.
Use Jest's "modern" fake timers instead of our Lolex wrapper.
Use Jest's "modern" fake timers instead of our Lolex wrapper.
Use Jest's "modern" fake timers instead of our Lolex wrapper.
We've entirely switched over to Jest's "modern" fake timers, which
landed in jestjs/jest#7776.
Also, remove several now-unnecessary calls of
`jest.useFakeTimers('modern')`, but keep a few assertions that the
"modern" timers are actually being used.

In particular, our `jestSetup` is a central place where we make the
assertion. Not only is it good to check that we still intentionally
set the "modern" implementation, but we want to make sure that the
setting is correctly applied. See the note in fb23341 about it
being silently not applied until we added @jest/source-map as a
direct dependency.

We have an ESLint rule, from 2faad06, preventing imports from
'**/__tests__/**'; the rule is active in all files not matching that
same pattern. Add an additional override so that we can make the
"modern"-timers assertion from within `jest/jestSetup.js`.
Follow and delete a code comment at the top of
`backoffMachine-test`, suggesting that we move these tests.
@gnprice
Copy link
Member

gnprice commented Aug 11, 2021

Thanks! Merging.

@gnprice gnprice merged commit 535ee6d into zulip:master Aug 11, 2021
@chrisbobbe
Copy link
Contributor Author

Thanks for the review!

chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this pull request Sep 9, 2021
This is our first use of `react-test-renderer`. It piggy-backs on
our incorporation of Jest's "modern" fake-timer implementation in
PRs zulip#4754 and zulip#4931. That was handy!

I haven't yet found any test cases that fail with our
implementation. (And I'd been hoping to, to debug an unexpected
error!)

But I did try pasting in an earlier iteration of the hook's
implementation, from zulip#4940, that Greg had found bugs in by reading
the code. Many of these tests failed on that buggy implementation,
which is a good sign.

Might as well keep these new tests, then, if they're not an
unreasonable maintenance burden.
chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this pull request Sep 9, 2021
This is our first use of `react-test-renderer`. It piggy-backs on
our incorporation of Jest's "modern" fake-timer implementation in
PRs zulip#4754 and zulip#4931. That was handy!

I haven't yet found any test cases that fail with our
implementation. (And I'd been hoping to, to debug an unexpected
error!)

But I did try pasting in an earlier iteration of the hook's
implementation, from zulip#4940, that Greg had found bugs in by reading
the code. Many of these tests failed on that buggy implementation,
which is a good sign.

Might as well keep these new tests, then, if they're not an
unreasonable maintenance burden.
chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this pull request Sep 10, 2021
This is our first use of `react-test-renderer`. It piggy-backs on
our incorporation of Jest's "modern" fake-timer implementation in
PRs zulip#4754 and zulip#4931. That was handy!

I haven't yet found any test cases that fail with our
implementation. (And I'd been hoping to, to debug an unexpected
error!)

But I did try pasting in an earlier iteration of the hook's
implementation, from zulip#4940, that Greg had found bugs in by reading
the code. Many of these tests failed on that buggy implementation,
which is a good sign.

Might as well keep these new tests, then, if they're not an
unreasonable maintenance burden.
chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this pull request Sep 10, 2021
This is our first use of `react-test-renderer`. It piggy-backs on
our incorporation of Jest's "modern" fake-timer implementation in
PRs zulip#4754 and zulip#4931. That was handy!

I haven't yet found any test cases that fail with our
implementation. (And I'd been hoping to, to debug an unexpected
error!)

But I did try pasting in an earlier iteration of the hook's
implementation, from zulip#4940, that Greg had found bugs in by reading
the code. Many of these tests failed on that buggy implementation,
which is a good sign.

Might as well keep these new tests, then, if they're not an
unreasonable maintenance burden.
@chrisbobbe chrisbobbe deleted the pr-uproot-lolex branch November 4, 2021 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants