Skip to content

test(vitest): share console setup and config defaults#7982

Open
joshblack wants to merge 3 commits into
mainfrom
joshblack/fail-on-console/setup
Open

test(vitest): share console setup and config defaults#7982
joshblack wants to merge 3 commits into
mainfrom
joshblack/fail-on-console/setup

Conversation

@joshblack

@joshblack joshblack commented Jun 12, 2026

Copy link
Copy Markdown
Member

Adds a shared private @primer/vitest-config package for Vitest console-failure enforcement and shared config defaults. Vitest projects now consume a shared defineConfig wrapper so common setup can stay centralized while console enforcement remains opt-in for downstream cleanup PRs.

Changelog

New

  • Shared Vitest setup package for console-failure enforcement.
  • Shared @primer/vitest-config/config entrypoint that wraps defineConfig with common Vitest defaults.

Changed

  • Vitest project configs now import defineConfig from @primer/vitest-config/config.
  • Shared Vitest defaults now centrally apply __VITEST_FAIL_ON_CONSOLE__ and setupFiles.
  • Shared setup now safely falls back when the injected console flag is unavailable in a given Vitest environment.

Removed

  • N/A

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; configuration-only test infrastructure.

Testing & Reviewing

Validated with build, targeted Vitest runs for the affected packages/configs, type-check, lint, CSS lint, and format checks. A full aggregated npm test -- --run still hit an unrelated existing AnchoredOverlay browser-suite failure, but the affected Vitest config paths exercised by this PR passed in targeted runs.

Merge checklist

@changeset-bot

changeset-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: a6439c2

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

@github-actions github-actions Bot added the staff Author is a staff member label Jun 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Action required

👋 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. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

To publish a canary release for integration testing, apply the Canary Release label to this PR.

@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 Jun 12, 2026
@joshblack joshblack added the skip changeset This change does not need a changelog label Jun 12, 2026
@joshblack joshblack changed the title joshblack/fail on console/setup test(vitest): add shared console setup Jun 12, 2026
@github-actions github-actions Bot temporarily deployed to storybook-preview-7982 June 12, 2026 17:04 Inactive
@joshblack joshblack force-pushed the joshblack/fail-on-console/setup branch from f419fb1 to cd99468 Compare June 12, 2026 17:29
@github-actions github-actions Bot temporarily deployed to storybook-preview-7982 June 12, 2026 17:41 Inactive
@joshblack joshblack force-pushed the joshblack/fail-on-console/setup branch from cd99468 to 0c91659 Compare June 12, 2026 18:31
@github-actions github-actions Bot temporarily deployed to storybook-preview-7982 June 12, 2026 18:43 Inactive
@joshblack joshblack force-pushed the joshblack/fail-on-console/setup branch from 0c91659 to 6aa9229 Compare June 15, 2026 16:24
@joshblack joshblack marked this pull request as ready for review June 15, 2026 16:24
Copilot AI review requested due to automatic review settings June 15, 2026 16:24
@joshblack joshblack requested a review from a team as a code owner June 15, 2026 16:24
@joshblack joshblack requested a review from liuliu-dev June 15, 2026 16:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new private workspace package (@primer/vitest-config) that centralizes Vitest setup for optional vitest-fail-on-console enforcement, and wires all existing Vitest project configs in the monorepo to load it.

Changes:

  • Added packages/vitest-config workspace with an exported Vitest setup file (@primer/vitest-config/setup).
  • Updated each package’s Vitest config (node + browser where applicable) to load the shared setup file and define __VITEST_FAIL_ON_CONSOLE__ based on process.env.VITEST_FAIL_ON_CONSOLE.
  • Updated package-lock.json to include the new workspace and vitest-fail-on-console dependency.
Show a summary per file
File Description
packages/vitest-config/tsconfig.json Adds TS config for the new shared Vitest setup workspace.
packages/vitest-config/src/setup.ts Implements opt-in vitest-fail-on-console setup behind a build-time flag.
packages/vitest-config/package.json Declares the new private workspace package, its export, and dependency.
packages/styled-react/vitest.config.ts Loads shared setup for node tests and defines the opt-in flag.
packages/styled-react/vitest.config.browser.ts Loads shared setup for browser tests and defines the opt-in flag.
packages/react/vitest.config.mts Loads shared setup for node tests and defines the opt-in flag.
packages/react/vitest.config.browser.mts Loads shared setup for browser tests and defines the opt-in flag.
packages/postcss-preset-primer/vitest.config.ts Loads shared setup for node tests and defines the opt-in flag.
packages/doc-gen/vitest.config.mts Loads shared setup for node tests and defines the opt-in flag.
package-lock.json Adds workspace link + locks vitest-fail-on-console (and dependency graph adjustments).

Copilot's findings

  • Files reviewed: 9/10 changed files
  • Comments generated: 0

@joshblack joshblack left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@copilot could you add a config entrypoint to vitest-config that exports a wrapper for defineConfig. vitest configs should pull from this instead (e.g. import {defineConfig} from '@primer/vitest-config/config') and then the helper should call defineConfig from vitest/config and merge in the input with the defaults we want in each config (like __VITEST_FAIL_ON_CONSOLE__ and setupFiles)

Co-authored-by: joshblack <3901764+joshblack@users.noreply.github.com>

Copilot AI commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

@copilot could you add a config entrypoint to vitest-config that exports a wrapper for defineConfig. vitest configs should pull from this instead (e.g. `import {defineConfig} from '@primer/vitest-co...

Addressed in a6439c2. Added @primer/vitest-config/config, switched the Vitest project configs to import its defineConfig wrapper, and kept the shared setup resilient when the injected define is unavailable.

Copilot AI changed the title test(vitest): add shared console setup test(vitest): share console setup and config defaults Jun 15, 2026
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 staff Author is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants