question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

test-utils package for common setup needed

See original GitHub issue

šŸ™‹ Feature Request

As adoption has increased, the common issues related to testing have also increased - should we include common helper functions such as mockRequestAnimationFrame or mockClientWindow into a package that we can export with RSP? I’m thinking maybe @react-spectrum/test-utils?

šŸ¤” Expected Behavior

Users shouldn’t need to worry about mocking animation frames or client windows

😯 Current Behavior

Currently, users have to run into the error and figure out that they need to mock those methods/values

šŸ’ Possible Solution

Option A: Figure out a jest setup that we can export and users can add to their config Option B: Absorb this npm package, add it to an exportable test-utils folder and add it to the documentation.

I’d prefer option A but don’t have a current solution for it, the package in option B is already typed and being used in production but it’s not the optimal dev experience (still involves the user facing the issue first, connecting the dots and then adding the mock function) .

šŸ”¦ Context

Seems like engineers are now facing this issue while testing almost daily, it’d be nice if we can address it

šŸ’» Examples

Similar methods are already being used within our RSP tests, such as

ListView mocking client window

ComboBox mocking request animation frame

🧢 Your Company/Team

Adobe

šŸŽ Tracking Ticket (optional)

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
reidbarbercommented, Nov 8, 2022

I have a DnD test util at https://github.com/adobe/react-spectrum/compare/main...dnd-test-util that might fit in here well.

1reaction
snowystingercommented, Nov 3, 2022

This is where I’ve been arriving as well and something I’ve implemented before in another project. I’m curious though on your thoughts if we implement it all as real or fake timers. Does that present issues if the person testing has decided one or the other for themselves.

In the previous project, we had some issues with these higher level test utils being brittle themselves. Though they were written for browser based integration tests which at the time were not great technologies. We also didn’t see great adoption of use for them, though that could have been a documentation issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setup - Testing Library
If you want to add custom queries globally, you can do this by defining a custom render method: Javascript; Typescript. test-utils.js. import {Ā ......
Read more >
testutils - Go Packages
NewIncomingCall creates an incoming call for tests. func NewServer ¶. func NewServer(t testing.TB, opts *ChannelOpts) *tchannel.Channel.
Read more >
GlenKPeterson/TestUtils: Utilities for testing `.equals ... - GitHub
Utilities for testing common Java/Kotlin contracts. Currently: equals(), hashCode(), and compareTo(). I find a bug almost every time I apply these tests to...
Read more >
@opentelemetry/contrib-test-utils - npm
This package exports a mocha root hook plugin, which implements common boilerplate code a developer probably needs for writing instrumentationĀ ...
Read more >
Import a test utils module from the test package with cabal
What do you mean by seems to not be possible exactly? Ā· I'm not a Cabal expert, but I think you may need...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found