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

test: fix interchange debonce test race condition #11279

Conversation

ncoden
Copy link
Contributor

@ncoden ncoden commented May 18, 2018

Description

Timeout delays are most often not respected and the differences between several timeouts running in parrallel can be huge. To prevent race conditions on slower browsers, we now run the debounce test several time to wait for the debounced event to be called, which may be finally called way after the expected time.

This is done using a new testInterval utility: it try and catch the given function every interval delay, until it succedes (does not throw an error) or a given time passed.

If the debounced event is was called when expected (just after 10ms), we wait and run the test again. If after many tries the debounced event is still not called after 1s, we consider the test as failed.

The test should be now safe enough regarding to race conditions.

Changes

  • Add testInterval test utility
  • Wait for debounce for slow browsers in Interval debounce test

References

Motivation and Context

Fixes the following race condition with IE11:

[Windows 8.1, Internet Explorer 11.0] Error: "calls reflow on viewport size change once" failed, expected _reflow to be called once but was called 0 times (http://localhost:8888/node_modules/sinon/pkg/sinon-no-sourcemaps.js:165)

-- https://travis-ci.org/zurb/foundation-sites/jobs/379941331#L1128

Types of changes

  • Documentation
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing
    functionality to change)

Checklist (all required):

  • I have read and follow the CONTRIBUTING document.
  • There are no other pull request similar to this one.
  • The pull request title is descriptive.
  • The template is fully and correctly filled.
  • The pull request targets the right branch (develop or support/*).
  • My commits are correctly titled and contain all relevant information.
  • My code follows the code style of this project.
  • I have updated the documentation accordingly to my changes (if relevant).
  • I have added tests to cover my changes (if relevant).
  • All new and existing tests passed.

ncoden added 3 commits May 18, 2018 22:00
Timeout delays are most often not respected and the differences between several timeouts running in parrallel can be huge. To prevent race conditions on slower browsers, we run the debounce test several time to wait for the debounced event to be called, which may be finally called way after the expected time.
@ncoden ncoden merged commit c3472a1 into foundation:develop May 21, 2018
ncoden added a commit to ncoden/foundation-sites that referenced this pull request Jun 16, 2018
…bonce-test-race-condition for v6.5.0

2bebd87 feat: add `testInterval` test utility
ad2a282 test: wait for debounce for slow browsers in Interval debounce test
33d009a docs: add doc for "tryInterval" test utility

Signed-off-by: Nicolas Coden <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants