-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
fix: getTimerCount not taking immediates and ticks into account #8139
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
Conversation
|
|
||
| if (uuid && this._timers.hasOwnProperty(uuid)) { | ||
| delete this._timers[String(uuid)]; | ||
| if (uuid && this._timers.has(uuid)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need the has check? I'd guess delete just no-ops if the key is not there
SimenB
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree this seems more correct.
Mind fixing CI and updating the changelog?
thymikee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed some changes to fix the tests and the new map implementation
SimenB
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still missing changelog, code LGTM
| private _ticks!: Array<Tick>; | ||
| private _timerAPIs: TimerAPI; | ||
| private _timers!: {[key: string]: Timer}; | ||
| private _timers!: Map<string, Timer>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically breaking, but meh. It's internal
9c0cd78 to
1a35a0b
Compare
|
Thanks you guys rock! |
* upstream/master: (391 commits) more precise circus asyncError types (jestjs#8150) Add typeahead watch plugin (jestjs#6449) fix: getTimerCount not taking immediates and ticks into account (jestjs#8139) website: add an additional filter predicate to backers (jestjs#7286) [🔥] Revised README (jestjs#8076) [jest-each] Fix test function type (jestjs#8145) chore: improve bug template labels for easier maintenance (jestjs#8141) Add documentation related to auto-mocking (jestjs#8099) Add support for bigint to pretty-format (jestjs#8138) Revert "Add fuzzing based tests in Jest (jestjs#8012)" chore: remove console.log chore: Improve description of optional arguments in ExpectAPI.md (jestjs#8126) Add fuzzing based tests in Jest (jestjs#8012) Move @types/node to the root package.json (jestjs#8129) chore: use property initializer syntax (jestjs#8117) chore: delete flow types from the repo (jestjs#8061) Move changelog entry to the proper version (jestjs#8115) Release 24.5.0 Expose throwOnModuleCollision (jestjs#8113) add matchers to expect type (jestjs#8093) ...
|
@xixixao do you think you could PR this to Lolex as well? In #5171 I'm trying to move to Lolex, and sinonjs/fake-timers#215 did not include ticks, so the new test fails 🙂 |
|
@xixixao ping (if you don't have time, that's of course perfectly fine) |
|
Hey Simen, I won't be able to get to this any time soon.
---------- Původní e-mail ----------
Od: Simen Bekkhus <[email protected]>
Komu: facebook/jest <[email protected]>
Datum: 13. 4. 2019 13:57:02
Předmět: Re: [facebook/jest] fix: getTimerCount not taking immediates and
ticks into account (#8139)
"
@xixixao(https://github.com/xixixao) ping
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
(#8139 (comment)), or mute
the thread
(https://github.com/notifications/unsubscribe-auth/ABZ7memYmX3khdRW4HiyUkwljJ1BX9huks5vgdQagaJpZM4b4dbp)
.
"
|
|
Thanks! I opened up sinonjs/fake-timers#238 so we don't forget 🙂 |
|
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. |
Summary
I assume this is how the getTimerCount method was supposed to work. Otherwise it's pretty useless.
I included moving to Map, so that the function doesn't incur an O(n) size check, because I'm running this in a pretty tight loop.
Test plan
Added unit test.