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

[Bug]: @storybook/test cause logging warning messages on @testing-library/dom@v10 and @testing-library/user-event #27173

Open
tnyo43 opened this issue May 16, 2024 · 0 comments · May be fixed by #27229

Comments

@tnyo43
Copy link

tnyo43 commented May 16, 2024

Describe the bug

(I don't think this is a bug, but it was the most suitable class I guess)

I have a test which has dependencies on "@testing-library/react@v15.0.7" and "@testing-library/user-event@v14.5.2".
After I installed the "@storybook/test@v8.0.10" library in the same repository, the following warning message displayed:

Warning: An update to Component inside a test was not wrapped in act(...).

When testing, code that causes React state updates should be wrapped into act(...):

act(() => {
  /* fire events that update state */
});
/* assert on the output */

It seems that the warning is caused by the difference of the version of "@testing-library/dom" (ref).

  • "@testing-library/react@v15.0.7" has dependency to ^10.0.0 (ref)
  • @testing-library/user-event@v14.5.2" just has a peerDependency to it
    • however, "@storybook/test" has dependency of both "user-event@^14.5.2" and "dom@^9.3.4" (ref)
    • it seems that the peerDependency of "user-event" to "dom" is affected by that and depends on "dom@^9.3.4"

I'm not sure if it is possible for "@storybook/test" to depend on "@testing-library/dom", but I hope it is so.

To Reproduce

  1. close the reproduction repository: https://github.com/tnyo43/reproduce-storybook-test-and-dom-dependency-problem
  2. run git checkout 39dad30be9faa3b5acdd9d228f6414ff55a5c71f (with @storybook/test)
  3. run pnpm install and pnpm test → you WILL see the warning message
  4. run git checkout 17f83f29b4c8912d7194d54d9ea284df3191980f (without @storybook/test)
  5. run pnpm install and pnpm test → you WILL NOT see the warning message

System

Storybook Environment Info:

  System:
    OS: macOS 14.1.2
    CPU: (10) arm64 Apple M2 Pro
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.16.0 - ~/.nodenv/versions/18.16.0/bin/node
    Yarn: 4.1.1 - ~/.nodenv/versions/18.16.0/bin/yarn <----- active
    npm: 9.5.1 - ~/.nodenv/versions/18.16.0/bin/npm
    pnpm: 9.0.6 - ~/.nodenv/versions/18.16.0/bin/pnpm
  Browsers:
    Chrome: 124.0.6367.208
    Safari: 17.1.2

Additional context

Now to avoid the dependency problem, I explicitly install "@testing-library/dom@v10.1.0" on my repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Empathy Backlog
Development

Successfully merging a pull request may close this issue.

4 participants