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

Improve testing with Recoil state #421

Merged
merged 4 commits into from
May 29, 2024
Merged

Conversation

kmcginnes
Copy link
Collaborator

@kmcginnes kmcginnes commented May 29, 2024

Description

Testing hooks with Recoil state was mocking hooks like useConfiguration() before. I want to actually execute all the logic within the Recoil selectors since so much of our logic is hidden in there.

So I've created a helper to make these tests easier to write. Using renderHookWithRecoilRoot() we are now able to wrap the hook call and provide an initial state setup function. This removes the need for mocks and allows this code to execute the full stack of recoil logic.

  • Update Jest config to enable TSX transpiling and use more defaults
  • Add renderHookWithRecoilRoot()
  • Add new random data generator for RawConfiguration
  • Use initial recoil state instead of mocking for many tests
  • Uninstall jest-localstorage-mock since it was no longer used

Validation

I focused on only change test setup and config. No logic changed. No test expectations changed.

  • Run the tests

Related Issues

Check List

  • I confirm that my contribution is made under the terms of the Apache 2.0
    license.
  • I have run pnpm checks to ensure code compiles and meets standards.
  • I have run pnpm test to check if all tests are passing.
  • I have covered new added functionality with unit tests if necessary.
  • I have added an entry in the Changelog.md.

@kmcginnes kmcginnes force-pushed the compile-tsx-in-tests branch from f344b59 to 0eb4bed Compare May 29, 2024 17:25
@kmcginnes kmcginnes marked this pull request as ready for review May 29, 2024 17:37
@kmcginnes kmcginnes requested a review from vkagamlyk May 29, 2024 17:37
@kmcginnes kmcginnes merged commit 307e0b1 into aws:main May 29, 2024
1 check passed
@kmcginnes kmcginnes deleted the compile-tsx-in-tests branch May 29, 2024 18:09
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.

2 participants