test(vitest): share console setup and config defaults#7982
Conversation
|
|
f419fb1 to
cd99468
Compare
cd99468 to
0c91659
Compare
0c91659 to
6aa9229
Compare
There was a problem hiding this comment.
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-configworkspace 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 onprocess.env.VITEST_FAIL_ON_CONSOLE. - Updated
package-lock.jsonto include the new workspace andvitest-fail-on-consoledependency.
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
6aa9229 to
ab1bb8e
Compare
joshblack
left a comment
There was a problem hiding this comment.
@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>
Addressed in a6439c2. Added |
Adds a shared private
@primer/vitest-configpackage for Vitest console-failure enforcement and shared config defaults. Vitest projects now consume a shareddefineConfigwrapper so common setup can stay centralized while console enforcement remains opt-in for downstream cleanup PRs.Changelog
New
@primer/vitest-config/configentrypoint that wrapsdefineConfigwith common Vitest defaults.Changed
defineConfigfrom@primer/vitest-config/config.__VITEST_FAIL_ON_CONSOLE__andsetupFiles.Removed
Rollout strategy
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 -- --runstill hit an unrelated existingAnchoredOverlaybrowser-suite failure, but the affected Vitest config paths exercised by this PR passed in targeted runs.Merge checklist