-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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]: Importing interaction stories in a test case and running them using .play
throws act
warnings
#25304
Comments
@yannbf @kasperpeulen is this something you can help with? |
@ndelangen @ghengeveld I thought we seen this before, and there was some resolution by changing the NODE_ENV? |
Wasn't that for the play function while it was running in Storybook? OP mentions it fails when using the play fn in portable stories |
@kasperpeulen I did some investigation and it seems like the act warning happens when using Here's the minimal repro using the OP's provided repro: /* eslint-disable testing-library/prefer-screen-queries */
import React from 'react'
import { screen as canvas, render } from '@testing-library/react'
import * as stories from './ActWarning.stories'
import { composeStories } from '@storybook/react'
import { userEvent } from '@storybook/test'
// import { userEvent } from '@testing-library/user-event'
const { Basic } = composeStories(stories)
describe('ActWarning from storybook', () => {
it('throws act warnings when ran', async () => {
render(<Basic />)
await userEvent.click(canvas.getByRole('button'))
})
}) I think we need to investigate this further |
I think this was supposed to say: |
@yannbf, @kasperpeulen any chance of getting this fixed? |
Has anyone found a workaround to this issue? My tests do seem to pass, just with the big warnings. I tried wrapping the |
@xveganxxxedgex we had problems with failures after wrapping play function in import type { ReactRenderer } from "@storybook/react";
import type {
ComposedStoryPlayContext,
ComposedStoryFn,
} from "@storybook/types";
import { act, waitFor } from "@testing-library/react";
type PlayFunctionThatReturnsPromise = (
options: ComposedStoryPlayContext<ReactRenderer>,
) => Promise<void>;
export const executePlayFunction = async (
Story: ComposedStoryFn<ReactRenderer>,
options: ComposedStoryPlayContext<ReactRenderer>,
) => {
let playFunctionCompleted = false;
const playFunction = Story.play as PlayFunctionThatReturnsPromise;
act(() => {
playFunction(options)
.then(() => {
playFunctionCompleted = true;
})
.catch((error) => {
throw error;
});
});
await waitFor(() => {
expect(playFunctionCompleted).toBe(true);
});
}; you can check it on some examples in microsoft/nova-facade#101 |
I'm still getting the same error on |
Describe the bug
Using
@testing-library/user-event
v14.5 and RTL dom v9.3.3While running the test
src/stories/ActWarning.test.jsx
, the test cases passes but the first test case silently throwsact
warningsTo Reproduce
clone https://github.com/ankitprahladsoni/storybook-act-warnings
run
yarn test
Observer the console for
act
warningSystem
No response
Additional context
Only the first test throws the act warning in the file
src/stories/ActWarning.test.jsx
, the rest of the two tests that aren't using the.play
api run normally without throwing any warning.The text was updated successfully, but these errors were encountered: