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

Interactions: assertions fail on first load #16872

Closed
bodograumann opened this issue Dec 2, 2021 · 6 comments
Closed

Interactions: assertions fail on first load #16872

bodograumann opened this issue Dec 2, 2021 · 6 comments

Comments

@bodograumann
Copy link
Contributor

Describe the bug
The expect assertion in a play function can fail, when it is run too early (I think).
In particular, when the storybook is just loaded.

To Reproduce
Go to https://next--storybookjs.netlify.app/official-storybook/?path=/story/addons-interactions-accountform--find-by

You will find, that the story fails. Due to being

Unable to find role="button"

If you rerun the play function, or already had the storybook loaded and just navigate to this specific story, everything is green however.

@stale
Copy link

stale bot commented Jan 9, 2022

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Jan 9, 2022
@stale stale bot removed the inactive label Jan 10, 2022
@shilman
Copy link
Member

shilman commented Jan 10, 2022

Sorry I missed this the first time around. Is it still a problem? Story looks like it's loading fine to me now.

@bodograumann
Copy link
Contributor Author

Yes, unfortunately it still fails on Firefox 95.0.2, Chromium 97.0.4692.71 and QtWebEngine 5.15.8 based on Chromium 87.

The console does not show much:
Screenshot_20220111-081839

In firefox it shows a lengthy manager log, probably because I have the react devtools installed. No errors though.

This is on Arch Linux with linux kernel 5.15.13-arch1-1

@shilman
Copy link
Member

shilman commented Jan 11, 2022

Thanks, got it to repro in Firefox 🙏

@lonyele
Copy link
Member

lonyele commented Mar 7, 2022

I looked at it and observed that if the code is using some waitFor, findBy* to wait for something, it can fail the test. Not only this FindBy but all other stories that use it.

some observations

  • bigger the difference between story's setTimeout's time and waitFor, findBy*'s time, the more possibility to pass the test. For this issue's FindBy case, if the code is setTimeout(() => setIsLoading(false), 10); it passes most of the time. if it is something like 500ms or 800ms that is near to findBy*'s default timeout 1000ms, then it fails most of the time.

I feel like this issue can be revisited later after #16492 is fixed. I suspect the current behavior that WAI examples(passing the test) all fails at first load -> flickers -> pass the test. Just my guess

@shilman
Copy link
Member

shilman commented Jun 16, 2022

Yo-ho-ho!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.0.0-alpha.3 containing PR #18460 that references this issue. Upgrade today to the @future NPM tag to try it out!

npx sb upgrade --prerelease

Closing this issue. Please re-open if you think there's still more to do.

@shilman shilman closed this as completed Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants