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

Set up Jest/testing library for tests #81

Closed
sergei-maertens opened this issue Dec 8, 2023 · 1 comment · Fixed by #82
Closed

Set up Jest/testing library for tests #81

sergei-maertens opened this issue Dec 8, 2023 · 1 comment · Fixed by #82
Assignees

Comments

@sergei-maertens
Copy link
Member

As an alternative to running (integration/unit) tests in Storybook, which is too flaky.

Viicos added a commit that referenced this issue Dec 8, 2023
Viicos added a commit that referenced this issue Dec 8, 2023
Viicos added a commit that referenced this issue Dec 8, 2023
Viicos added a commit that referenced this issue Dec 8, 2023
Viicos added a commit that referenced this issue Dec 8, 2023
Viicos added a commit that referenced this issue Dec 8, 2023
Viicos added a commit that referenced this issue Dec 8, 2023
Viicos added a commit that referenced this issue Dec 12, 2023
Viicos added a commit that referenced this issue Dec 12, 2023
Viicos added a commit that referenced this issue Dec 13, 2023
Move shared test utils to a common file
Exclude files so that we don't have to ignore specific types files
Viicos added a commit that referenced this issue Dec 13, 2023
Viicos added a commit that referenced this issue Dec 13, 2023
Viicos added a commit that referenced this issue Dec 13, 2023
Viicos added a commit that referenced this issue Dec 13, 2023
Viicos added a commit that referenced this issue Dec 13, 2023
Move shared test utils to a common file
Exclude files so that we don't have to ignore specific types files
Viicos added a commit that referenced this issue Dec 13, 2023
sergei-maertens added a commit that referenced this issue Dec 14, 2023
Note that the components fetch available dropdown options asynchronously, which leads to
act warnings typically because the state updates happen outside of the initial
render and are thus unexpected.

These useEffect-based things run despite there not being any explicit user interaction
(which is automatically wrapped in act via @testing-library/user-event). Instead, we
can set up the jest fake timers so that we can still assert the loading state before
it resolves, perform the user interactions and use the async queries to assert the
expected final state, without having any act warnings.

To be fair I don't 100% understand how the timer advancing works, but the tests
seem to work when putting assertions in that should not pass (the test fails
as expected) and we can assert the in-between/loading states, without getting
any act warnings, so I'll take it.
Viicos added a commit that referenced this issue Dec 14, 2023
Viicos added a commit that referenced this issue Dec 14, 2023
Viicos added a commit that referenced this issue Dec 14, 2023
sergei-maertens added a commit that referenced this issue Dec 14, 2023
sergei-maertens added a commit that referenced this issue Dec 14, 2023
This should be more reliable and not depend on browser-specific
race conditions/unpredictable interactions with jest/testing-library.
@sergei-maertens sergei-maertens linked a pull request Dec 15, 2023 that will close this issue
@sergei-maertens
Copy link
Member Author

Completed via #82

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

Successfully merging a pull request may close this issue.

2 participants