Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 31, 2025

Vitest 4.0.16 rejects calling suite functions inside test execution contexts. The storybook test file violated this by dynamically creating describe() blocks inside a describe.each() callback's for loop.

Before:

describe.each(components)('%s', (_component, stories) => {
  for (const {story, type, relativeFilepath} of stories) {
    describe(`${story.default.title} (${relativeFilepath})`, () => {
      test('...', () => { /* ... */ })
    })
  }
})

After:

const flattenedStories = stories.map(story => ({
  testName: `${story.name} - ${story.story.default.title} (${story.relativeFilepath})`,
  ...story,
}))

describe.each(flattenedStories)('$testName', ({story, type}) => {
  test('...', () => { /* ... */ })
})

Changelog

Changed

  • Refactored storybook.test.tsx to flatten story array and avoid nested describe() calls
  • Removed lodash.groupby dependency from test file

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

All 312 storybook tests pass with identical coverage. Test names now include component name, title, and filepath for easier identification.

Merge checklist

Original prompt

Fix the failing GitHub Actions workflow test (react-18)

Analyze the workflow logs, identify the root cause of the failure, and implement a fix.

Job ID: 59174290156

Job URL: https://github.com/primer/react/actions/runs/20603536604/job/59174290156


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@changeset-bot
Copy link

changeset-bot bot commented Dec 31, 2025

⚠️ No Changeset found

Latest commit: abc60a4

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

Refactored the storybook.test.tsx to avoid calling describe() inside describe.each() callback. Vitest 4.0.16 introduced stricter rules about when suite functions can be called. The previous pattern used a for loop inside describe.each() to dynamically create nested describe blocks, which is now rejected.

Changed to use describe.each() directly with flattened stories array instead of grouping by component name and creating nested describes.

Co-authored-by: francinelucca <[email protected]>
@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Dec 31, 2025
@github-actions
Copy link
Contributor

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Or, apply the integration-tests: skipped manually label to skip these checks.

@francinelucca francinelucca added the skip changeset This change does not need a changelog label Dec 31, 2025
Copilot AI changed the title [WIP] Fix failing GitHub Actions workflow test for React 18 Fix storybook tests for vitest 4.0.16 compatibility Dec 31, 2025
Copilot AI requested a review from francinelucca December 31, 2025 01:57
@francinelucca
Copy link
Member

@copilot CI is still failing

Copy link
Contributor Author

Copilot AI commented Dec 31, 2025

@copilot CI is still failing

The storybook tests pass locally with vitest 4.0.16 (all 312 tests pass). Could you share the specific error message from the CI logs so I can investigate the failure?

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/primer/react/actions/runs/20610028963/logs
    • Triggering command: /usr/bin/curl curl -H Accept: application/vnd.github.v3&#43;json REDACTED -L (http block)

If you need me to access, download, or install something from one of these locations, you can either:

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

Labels

integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm skip changeset This change does not need a changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants