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

Make preferences reducer deterministic (again) #5518

Merged
merged 2 commits into from
Mar 9, 2018

Conversation

noisysocks
Copy link
Member

In #5423, we updated INSERT_BLOCKS and REPLACE_BLOCKS to contain a time property which contains the current timestamp (Date.now()). This required updating our effects tests to be less strict in what they asserted. Namely, we had to allow time to be any number (expect.any( Number )).

Unfortunately, I made a mistake and did not update two tests that needed to be less strict. npm test and Travis CI did not catch my mistake as the tests happened to run fast enough such that Date.now() returned the same timestamp for both the expected result and the actual result. I reverted the PR (#5517) when I noticed the error showing up in unrelated Travis builds.

This PR reverts the revert and updates the two test cases that I missed. To check that I correctly handled every case, I applied this diff and ran npm test.

😅

da00a9a did not update two tests which sometimes fail due to an action's
`time` being the current unix timetamp.
@noisysocks noisysocks requested a review from aduth March 9, 2018 00:46
@gziolo
Copy link
Member

gziolo commented Mar 9, 2018

You can also mock Date object as suggested in Jest repository here: jestjs/jest#2234 (comment)

Date.now = jest.fn() or global.Date = jest.fn().

Otherwise, everything looks good 👍

@gziolo gziolo added [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. [Type] Enhancement A suggestion for improvement. labels Mar 9, 2018
@noisysocks noisysocks merged commit 26938b1 into master Mar 9, 2018
@noisysocks noisysocks deleted the fix/make-reducer-and-tests-deterministic branch March 9, 2018 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants