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

test: mock useIsMounted to prevent intermittently failing tests #1505

Merged

Conversation

nobe4
Copy link
Contributor

@nobe4 nobe4 commented Feb 12, 2024

Description

When determining the place information by name, useIsMounted is called to determine if the boundingBox must be set.
See: src/landscape/components/LandscapeForm/BoundaryStep/index.js

During tests, it was found that useIsMounted returns sometimes true, sometimes false. This causes tests to sometimes uses the response from getPlaceInfoByName, and sometimes to not.

During tests, it seemed that the response should always be the non-mounted one. Mocking useIsMounted enforces this for all tests.

I could confirm locally that sometimes the test fails. After the update, it never failed again; hopefully it won't fail on CI.

When determining the place information by name, `useIsMounted` is called to
determine if the boundingBox must be set.
See: src/landscape/components/LandscapeForm/BoundaryStep/index.js

During tests, it was found that `useIsMounted` returns sometimes true,
sometimes false. This causes tests to sometimes uses the response from
`getPlaceInfoByName`, and sometimes to not.

During tests, it seemed that the response should always be the non-mounted one.
Mocking `useIsMounted` enforces this for all tests.
Jest will happily mock even non-imported objects, and the codestyle imposes to
use all defined variables.
@nobe4 nobe4 force-pushed the fix_intermitently_failing_tests branch from e97b441 to e0932b3 Compare February 12, 2024 19:51
@paulschreiber paulschreiber merged commit 08f7902 into techmatters:main Mar 1, 2024
6 of 7 checks passed
@nobe4 nobe4 deleted the fix_intermitently_failing_tests branch March 4, 2024 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants