Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

[Bug]: userEvent.type doesn't trigger onChange during hot reload #48

Open
david-morris opened this issue Jul 12, 2023 · 2 comments
Open

Comments

@david-morris
Copy link

david-morris commented Jul 12, 2023

Describe the bug
When I call userEvent.type in a play function, hot reloading the story causes the typing to update the form value but not trigger onChange.
doing things that take up time --- even an entire second --- doesn't prevent this behavior, but using userEvent.hover before userEvent.type might make it less likely. It's an intermittent bug.

To Reproduce
Steps to reproduce the behavior:

  1. Build a story with Chakra UI inputs that has a search input with an onChange
  2. add a userEvent.type and some expect that shows that the onChange was triggered
  3. Cause storybook to hot-load (it may fail)
  4. re-run the action (it succeeds)

Expected behavior
userEvent.type should always trigger onChange

Screenshots
After automatically running the play function because it was edited:
image
After hitting "rerun" on the test:
image

System

Environment Info:

  System:
    OS: Linux 5.15 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
    CPU: (16) x64 AMD Ryzen 7 PRO 4750U with Radeon Graphics
  Binaries:
    Node: 18.16.1 - /usr/local/share/nvm/versions/node/v18.16.1/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.5.1 - /usr/local/share/nvm/versions/node/v18.16.1/bin/npm
  npmPackages:
    @storybook/addon-essentials: 7.0.23 => 7.0.23 
    @storybook/addon-interactions: 7.0.23 => 7.0.23 
    @storybook/core-common: ^7.0.23 => 7.0.23 
    @storybook/core-server: 7.0.23 => 7.0.23 
    @storybook/jest: ^0.1.0 => 0.1.0 
    @storybook/nextjs: 7.0.23 => 7.0.23 
    @storybook/test-runner: ^0.11.0 => 0.11.0 
    @storybook/testing-library: ^0.2.0 => 0.2.0 

Additional context

  • yes, I am remembering to await the userEvent
  • adding more events might have some influence on whether it does this --- possibly a race condition?
  • Oddly, using fireEvent.input does not have this issue, even though it never hands over aysnc control.
@qaalib101
Copy link

@david-morris Any updates on this? Running into the same issue.

@david-morris
Copy link
Author

I switched to using fireEvent.input.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants