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

deflake LearningGoals by switching from useMemo to useEffect #64283

Merged
merged 6 commits into from
Mar 4, 2025

Conversation

davidsbailey
Copy link
Member

@davidsbailey davidsbailey commented Mar 4, 2025

Follows #64282. Speculative fix for https://codedotorg.atlassian.net/browse/TEACH-1639. Done in this PR:

  • clean up the afterInit event handler as soon and reliably as possible via useEffect, rather than waiting until test cleanup
  • converted the corresponding test case to RTL, because enzyme shallow rendering does not trigger useEffect callbacks

A few reasons why my attention was drawn to this as a potential fix:

  • googling the error message suggests a problem with timers or listeners
  • LearningGoalsTest uses studioApp while other rubrics tests do not
  • useMemo is not the right tool for triggering side effects, even in cases where you do not use a cleanup function

Testing story

  • updated unit tests

Deployment strategy

merge #64282 and this PR into staging. wait a few days before merging any additional follow up work.

Future work

potential next steps:

  • modernize LearningGoalsTest by switching fully to RTL and Jest.
  • experiment with jest --detectOpenHandles (requires a repro, too slow to add to ci)

@davidsbailey davidsbailey marked this pull request as ready for review March 4, 2025 19:11
Base automatically changed from split-learning-goals-test to staging March 4, 2025 19:12
@davidsbailey davidsbailey merged commit f1fe414 into staging Mar 4, 2025
3 of 4 checks passed
@davidsbailey davidsbailey deleted the use-effect-learning-goals-test branch March 4, 2025 21:38
@davidsbailey davidsbailey restored the use-effect-learning-goals-test branch March 4, 2025 21:38
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