-
Notifications
You must be signed in to change notification settings - Fork 159
test(e2e): add toast interaction tests #2012
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
Conversation
|
✅ PR title follows Conventional Commits specification. |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 890da22:
|
/* eslint-disable @typescript-eslint/explicit-function-return-type */ | ||
/* eslint-disable import/no-extraneous-dependencies */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do I run these tests locally? Do we have a guide?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yarn test:react:interaction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
@snitin315 more info on here: https://storybook.js.org/docs/writing-tests/interaction-testing
You can also check example code for Popover, Carousel etc interaction tests.
await expect(queryByText(toastContent)).not.toBeInTheDocument(); | ||
const button = getByRole('button', { name: 'Show Toast' }); | ||
await userEvent.click(button); | ||
await sleep(400); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await waitFor(() => )
instead of sleep
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried it before, doesn't work. We need to discreetly wait for the animations to finish before asserting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The exit would depend on absolute duration no? but I am guessing the toast opens immediately on button click. So can we not use waitFor on those parts? and keep sleep where we want to actually wait for some duration for toast to disappear etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So can we not use waitFor on those parts
Maybe somethings wrong with storybook testing lib, it doesn't work with waitFor. You need to wait for a discreet amount of time.
Description
Changes
Additional Information
Component Checklist