Skip to content

chore: upgrade vitest and @vitest/ui to 4.1.2#16154

Merged
GermanJablo merged 3 commits into
mainfrom
chore/upgrade-vitest-4.1
Apr 7, 2026
Merged

chore: upgrade vitest and @vitest/ui to 4.1.2#16154
GermanJablo merged 3 commits into
mainfrom
chore/upgrade-vitest-4.1

Conversation

@GermanJablo

@GermanJablo GermanJablo commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Bump vitest from 4.0.15 to 4.1.2 (root + test/)
  • Bump @vitest/ui from 4.0.15 to 4.1.2 (root)
  • Fix graphql module alias in vitest.config.ts for compatibility with Vitest 4.1's new module runner

graphql alias fix

Vitest 4.1 replaced the default SSR environment runner with a new Vite module runner that loads "inlined" modules in its own context and "external" modules via Node's native import. This caused the graphql package to be loaded twice (two separate module instances), breaking all instanceof checks (e.g. isScalarType, new GraphQLList).

The previous alias (graphql: 'node_modules/graphql/index.js') also no longer worked because pnpm's isolated linker doesn't hoist graphql to root node_modules/.

Fix: use createRequire to resolve the actual graphql location from packages/graphql/ (where it's a direct dependency), then use regex-based aliases to handle both the main import and subpath imports (e.g. graphql/execution/values.js), pointing the main import to the CJS entry (index.js) to ensure a single module identity.

This unlocks native test tags support (--tags-filter CLI) which will be used in a follow-up PR to tag tests by feature category (GIS, transactions, migrations, etc.).

Test plan

  • CI passes (all existing integration tests should continue to work unchanged)
  • Verified locally: auth, collections-graphql, collections-rest, fields, database suites all pass

@github-actions

github-actions Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

📦 esbuild Bundle Analysis for payload

This analysis was generated by esbuild-bundle-analyzer. 🤖
This PR introduced no changes to the esbuild bundle! 🙌

paulpopus
paulpopus previously approved these changes Apr 7, 2026
@GermanJablo GermanJablo changed the base branch from 4.0 to main April 7, 2026 18:46
@GermanJablo GermanJablo dismissed paulpopus’s stale review April 7, 2026 18:46

The base branch was changed.

Bump from 4.0.15 to 4.1.2. No breaking changes.
Unlocks native test tags support (--tags-filter) for future use.
Vitest 4.1 changed how relative alias paths are resolved.
Use path.resolve to produce an absolute path.
Vitest 4.1's new module runner loads inlined and external modules in
separate contexts, causing duplicate graphql instances and failing
instanceof checks. The previous alias `node_modules/graphql/index.js`
no longer works because pnpm doesn't hoist graphql to root node_modules.

Fix: use createRequire to locate graphql from packages/graphql (where it
is a direct dependency), then set regex-based aliases that handle both
the main import and subpath imports (e.g. graphql/execution/values.js),
pointing all to the CJS entry to ensure a single module identity.
@GermanJablo GermanJablo force-pushed the chore/upgrade-vitest-4.1 branch from ce92145 to fc1345f Compare April 7, 2026 18:48
@GermanJablo GermanJablo merged commit 5af591c into main Apr 7, 2026
311 of 314 checks passed
@GermanJablo GermanJablo deleted the chore/upgrade-vitest-4.1 branch April 7, 2026 19:46
@github-actions

github-actions Bot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

🚀 This is included in version v3.82.0

milamer pushed a commit to milamer/payload that referenced this pull request Apr 20, 2026
## Summary

- Bump `vitest` from 4.0.15 to 4.1.2 (root + test/)
- Bump `@vitest/ui` from 4.0.15 to 4.1.2 (root)
- Fix `graphql` module alias in `vitest.config.ts` for compatibility
with Vitest 4.1's new module runner

### graphql alias fix

Vitest 4.1 replaced the default SSR environment runner with a new Vite
module runner that loads "inlined" modules in its own context and
"external" modules via Node's native import. This caused the `graphql`
package to be loaded twice (two separate module instances), breaking all
`instanceof` checks (e.g. `isScalarType`, `new GraphQLList`).

The previous alias (`graphql: 'node_modules/graphql/index.js'`) also no
longer worked because pnpm's isolated linker doesn't hoist `graphql` to
root `node_modules/`.

Fix: use `createRequire` to resolve the actual `graphql` location from
`packages/graphql/` (where it's a direct dependency), then use
regex-based aliases to handle both the main import and subpath imports
(e.g. `graphql/execution/values.js`), pointing the main import to the
CJS entry (`index.js`) to ensure a single module identity.

This unlocks native test tags support (`--tags-filter` CLI) which will
be used in a follow-up PR to tag tests by feature category (GIS,
transactions, migrations, etc.).

## Test plan

- [ ] CI passes (all existing integration tests should continue to work
unchanged)
- Verified locally: `auth`, `collections-graphql`, `collections-rest`,
`fields`, `database` suites all pass

---------

Co-authored-by: German Jablonski <GermanJablo@users.noreply.github.com>
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