Skip to content

test-helpers: Add useSandbox test helper#6301

Merged
aduth merged 7 commits intomainfrom
aduth-use-sandbox
May 4, 2022
Merged

test-helpers: Add useSandbox test helper#6301
aduth merged 7 commits intomainfrom
aduth-use-sandbox

Conversation

@aduth
Copy link
Contributor

@aduth aduth commented May 4, 2022

Why:

  • It already exists in spec, but isn't currently accessible to package specs
  • For convenience:
    • Automatic clean-up after spec
    • Delayed initialization of fake timers
    • Support sustained reference to destructured functions
      • Useful for userEvent.setup({ advanceTimers: clock.tick })
  • Improved testability for the behavior of the helper itself

aduth added 7 commits May 4, 2022 09:46
**Why**: For better organization, and so that it's accessible to package specs.
Since it's the most common method called, and to allow it to be stored as a reference and called later
changelog: Internal, Automated Testing, Add test helper for JavaScript stubbing sandbox
@aduth aduth requested a review from nprimak May 4, 2022 14:21
Copy link
Contributor

@zachmargolis zachmargolis left a comment

Choose a reason for hiding this comment

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

LGTM

@aduth aduth merged commit 751ce17 into main May 4, 2022
@aduth aduth deleted the aduth-use-sandbox branch May 4, 2022 16:49
peggles2 pushed a commit that referenced this pull request May 5, 2022
* Move useSandbox to test-helpers package

**Why**: For better organization, and so that it's accessible to package specs.

* Add support for destructured sandbox clock

* Special-case clock tick destructure proxy

Since it's the most common method called, and to allow it to be stored as a reference and called later

* Convert existing package spec sandboxes to use test helper

Much more convenient

* Create passthrough proxy for clock implementation

* Add basic spec for clean-up behavior

* Add changelog

changelog: Internal, Automated Testing, Add test helper for JavaScript stubbing sandbox
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants