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

feat: add fakeTimersLolex to the test environments #8925

Merged
merged 2 commits into from Sep 8, 2019

Conversation

SimenB
Copy link
Member

@SimenB SimenB commented Sep 7, 2019

Summary

In my continuing quest to land Lolex, this PR deals with adding it to the environments. There's no way to activate them, but a user can do

import NodeEnvironment = require('jest-environment-node');

export = class NodeEnvironmentLolex {
  constructor(...args) {
    super(...args);

    this.fakeTimers = this.fakeTimersLolex;
  }
};

and then use that custom environment. A couple of caveats, though - using runAllImmediates will throw since it's not implemented, and there's no way to access setSystemTime

Test plan

Tests added. The PR for actually making it accessible via API will include more tests, this is just threading through.

TestUtils.ts Show resolved Hide resolved
@codecov-io
Copy link

codecov-io commented Sep 7, 2019

Codecov Report

Merging #8925 into master will decrease coverage by <.01%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8925      +/-   ##
==========================================
- Coverage   64.28%   64.28%   -0.01%     
==========================================
  Files         276      276              
  Lines       11711    11715       +4     
  Branches     2866     2868       +2     
==========================================
+ Hits         7529     7531       +2     
- Misses       3550     3552       +2     
  Partials      632      632
Impacted Files Coverage Δ
packages/jest-fake-timers/src/FakeTimersLolex.ts 69.76% <100%> (ø) ⬆️
packages/jest-environment-node/src/index.ts 48.57% <40%> (+0.08%) ⬆️
packages/jest-environment-jsdom/src/index.ts 39.13% <50%> (+0.49%) ⬆️

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 a7f2d0d...c96a3b1. Read the comment docs.

Copy link
Collaborator

@thymikee thymikee left a comment

Choose a reason for hiding this comment

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

Should we somehow mark/comment that it's only temporary and not an official API? On the other hand we don't document it yet, so maybe no need to do it.

@SimenB
Copy link
Member Author

SimenB commented Sep 8, 2019

It's the same code the api will use

@SimenB SimenB merged commit 0935f7c into jestjs:master Sep 8, 2019
@SimenB SimenB deleted the add-lolex-to-envs branch September 8, 2019 13:10
@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 11, 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.

None yet

4 participants