Skip to content

test(core): fix deprecated act() warnings + await expect().rejects#332

Merged
kimyouknow merged 3 commits into
toss:mainfrom
dev-dino22:test/fix-warnings
Mar 4, 2026
Merged

test(core): fix deprecated act() warnings + await expect().rejects#332
kimyouknow merged 3 commits into
toss:mainfrom
dev-dino22:test/fix-warnings

Conversation

@dev-dino22

@dev-dino22 dev-dino22 commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

Overview

Fix Warnings

1. act()

1.1. warnings

act-warning

Updates were not wrapped in act(), causing warnings.
The environment where we run tests (Node.js + jsdom) is not a real browser. However, wrapping updates in act() ensures React simulates the exact scheduling and rendering sequence from a real browser environment.
This guarantees assertions run after rendering is fully complete.

Reference: react.dev/reference/react/act

Thus, we wrapped update operations in act() as follows:

await act(async () => {
      actions.set(1, 'added');
      rerender();
});

expect(result.current[0].get(1)).toBe('added');

Commit: test(core): wrap useMap mutations in act()

1.2. await act(async () ⇒ {})

notice

Additionally, React documentation states that synchronous act() usage is not safe in all cases and the synchronous version may be deprecated in the future.
This is because React now processes updates in priority-based batches, making it safer to wait for act() completion before proceeding.

Reference: react.dev/reference/react/act

Thus, we converted all synchronous act() calls to asynchronous usage.

Commit: test(core): replace deprecated sync act() with await act(async)

2. await expect(promise)

await-expect

In useStorageState.spec.ts, Promise-returning expect() statements were used without await.
Vitest currently auto-waits these assertions at test end, but warns they will fail in the future.

Thus, we added await to all Promise-based assertions.

Commit: test(core): await expect().rejects in useStorageState tests

3. After Completion

clean

Tests now complete without warnings.

Checklist

  • Did you write the test code?
  • Have you run yarn run fix to format and lint the code and docs?
  • Have you run yarn run test:coverage to make sure there is no uncovered line?
  • Did you write the JSDoc?

@kimyouknow kimyouknow left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dev-dino22 Welcome and thank you for this contribution!

The PR description is well-structured with clear screenshots and references. Review confirms all changes are correct:

  • ✅ Sync act()await act(async () => {}) across 17 test files
  • ✅ Properly wraps bare mutations in useMap.spec.ts with act() (the most meaningful fix)
  • ✅ Adds await to expect().rejects in useStorageState.spec.ts
  • ✅ All test functions correctly marked as async
  • ✅ Helper function in useImpressionRef.spec.ts also properly converted

Great first contribution! 🎉

@kimyouknow kimyouknow merged commit 43a1173 into toss:main Mar 4, 2026
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