Skip to content

test(react): cover NODE_ENV guard on ErrorBoundaryGroupContext displayName - #1990

Open
Archibald1948 wants to merge 1 commit into
toss:mainfrom
Archibald1948:test-error-boundary-group-context-display-name
Open

Archibald1948 wants to merge 1 commit into
toss:mainfrom
Archibald1948:test-error-boundary-group-context-display-name

Conversation

@Archibald1948

Copy link
Copy Markdown
Contributor

Overview

Related to #1464 (100% coverage). Follow-up to #1987.

ErrorBoundaryGroupContext only gets a displayName when NODE_ENV is 'development' (packages/react/src/ErrorBoundaryGroup.tsx L22). Since vitest.setup.ts stubs NODE_ENV to 'development' for every test, the production branch was never exercised, which left this file at 90% branch coverage.

This PR adds a parameterized test that stubs NODE_ENV, resets the module registry with vi.resetModules(), and dynamically re-imports ./ErrorBoundaryGroup so the module-level guard is evaluated under each environment:

  • development → displayName is 'ErrorBoundaryGroupContext'
  • production → displayName is undefined

afterEach restores the development stub and resets modules again, following the same pattern used in ErrorBoundary.spec.tsx.

Result

  • ErrorBoundaryGroup.tsx: branch coverage 90% → 100%
  • @suspensive/react package branch coverage: 95.71% → 96.42%
  • I also checked that the test catches regressions: replacing the guard with if (true) makes the production case fail.

Test-only change, so no changeset.

PR Checklist

  • I did below actions if need
  1. I read the Contributing Guide
  2. I added documents and tests.

🤖 Generated with Claude Code

…yName

ErrorBoundaryGroupContext only gets its displayName when NODE_ENV is
'development'. vitest.setup.ts stubs NODE_ENV to 'development' for every
test, so the production branch was never exercised. Re-import the module
under each NODE_ENV with vi.resetModules() to cover both branches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Oct 17, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 0e828e8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coauthors

coauthors Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

People can be co-author:

Candidate Reasons Count Add this as commit message
@Archibald1948 #1990 #1990 (comment) 2 Co-authored-by: Archibald1948 <176382683+Archibald1948@users.noreply.github.com>
@codecov-commenter #1990 (comment) 1 Co-authored-by: codecov-commenter <65553080+codecov-commenter@users.noreply.github.com>

@vercel

vercel Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

@Archibald1948 is attempting to deploy a commit to the Toss Team on Vercel.

A member of the Team first needs to authorize it.

@Archibald1948

Copy link
Copy Markdown
Contributor Author

@kangju2000
review plz :)

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.22%. Comparing base (5b76bda) to head (0e828e8).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1990   +/-   ##
=======================================
  Coverage   93.22%   93.22%           
=======================================
  Files          42       42           
  Lines         664      664           
  Branches      163      163           
=======================================
  Hits          619      619           
  Misses         42       42           
  Partials        3        3           
Components Coverage Δ
@suspensive/react 100.00% <ø> (ø)
@suspensive/react-query 95.83% <ø> (ø)
@suspensive/react-query-4 100.00% <ø> (ø)
@suspensive/react-query-5 100.00% <ø> (ø)
@suspensive/jotai 100.00% <ø> (ø)
@suspensive/codemods 81.60% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants