Skip to content

chore: consolidate vitest execution - #29039

Closed
dulmandakh wants to merge 9 commits into
prisma:mainfrom
dulmandakh:vitest-consolidate-execution
Closed

dulmandakh wants to merge 9 commits into
prisma:mainfrom
dulmandakh:vitest-consolidate-execution

Conversation

@dulmandakh

@dulmandakh dulmandakh commented Jan 17, 2026 •

Copy link
Copy Markdown
Contributor

This PR consolidates Vitest execution utilizing its concurrency management thus improve DX.

Summary by CodeRabbit

  • Tests

    • Centralized test discovery and execution under Vitest with a new root config and added per-package Vitest configs.
    • CI test job renamed to vitest-unit-tests, streamlined steps into a single Vitest run, and expanded Node.js matrix for broader coverage.
    • Multiple test suites migrated from Jest to Vitest (imports, mocks, timers).
  • Chores

    • Removed many per-package test scripts and legacy Jest/formatter config files to consolidate test execution.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 17, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

Consolidates per-package tests into a centralized Vitest setup: adds root and package Vitest configs, removes many package-level test scripts and Jest configs, updates tests to Vitest semantics, and updates CI to run pnpm vitest run in a renamed vitest-unit-tests job (expanded Node matrix).

Changes

Cohort / File(s) Summary
CI/CD Workflow Refactoring
.github/workflows/test-template.yml
Renamed job driver-adapter-unit-tests → vitest-unit-tests; removed many per-package test steps; added centralized pnpm vitest run step; expanded Node matrix to include 22.12.0.
Root Vitest Configuration
vitest.config.ts
New root multi-project Vitest config with server.watch.ignored, test.projects across packages/* (with exclusions), and testTimeout set to 30000.
Package Vitest Configs
packages/client-common/vitest.config.ts, packages/client-generator-registry/vitest.config.ts, packages/dmmf/vitest.config.ts, packages/ts-builders/vitest.config.ts
New per-package Vitest configs exporting default config that appends 'dist/*' to test.exclude.
Tests — Framework Migration & Small Fixes
packages/client-generator-js/tests/generator.test.ts, packages/client-generator-ts/tests/generator.test.ts, packages/query-plan-executor/src/logic/adapter.test.ts, packages/client-engine-runtime/src/**/*.test.ts, packages/get-platform/src/__tests__/*
Updated tests to Vitest imports (describe/test/expect), migrated Jest mocks/timers to vi, adjusted inline snapshot paths, and changed one mock to a function expression to preserve this binding.
Removed per-package test scripts & Jest configs
packages/*/package.json (adapters, client-, engines, fetch-engine, dmmf, ts-builders, schema-files-loader, instrumentation, sqlcommenter-, credentials-store, generator, query-plan-executor, etc.), packages/engines/jest.config.js, packages/fetch-engine/jest.config.js, packages/client-engine-runtime/jest.config.js, packages/get-platform/jestSnapshotSerializer.js, packages/get-platform/src/test-utils/jestContext.ts
Deleted many "test": "vitest run" / "test": "jest" script entries and removed several package-level Jest config and Jest-related test utilities/snapshot serializer files.
Formatting config removals
packages/generator-helper/.prettierignore, packages/generator-helper/.prettierrc.yml, packages/client-engine-runtime/.prettierignore, packages/client-engine-runtime/.prettierrc.yml
Removed Prettier config and ignore files from specified packages.
Package.json housekeeping
packages/client-engine-runtime/package.json, packages/get-platform/package.json, various packages/*/package.json
Removed @types/jest devDependency (client-engine-runtime), removed test and some prepublishOnly scripts, added packaging flags (dist/sideEffects in get-platform).

Sequence Diagram(s)

sequenceDiagram
  participant GH as "GitHub Actions"
  participant Runner as "Runner (no-docker)"
  participant Node as "Node / pnpm"
  participant Vitest as "Vitest"
  participant Packages as "Monorepo Packages"

  GH->>Runner: trigger job vitest-unit-tests (matrix)
  Runner->>Node: checkout & setup Node, pnpm install
  Runner->>Node: run `pnpm vitest run`
  Node->>Vitest: start multi-project discovery (vitest.config.ts)
  Vitest->>Packages: discover & run tests across packages (exclusions applied)
  Packages-->>Vitest: test results
  Vitest-->>Node: aggregated results
  Node-->>Runner: exit status
  Runner-->>GH: job result
Loading

Possibly related PRs

Suggested labels

lgtm

Suggested reviewers

  • aqrln
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore: consolidate vitest execution' directly summarizes the main change: consolidating Vitest execution across the codebase using centralized configuration and removing per-package test scripts.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/test-template.yml (1)

904-927: Make the Vitest config explicit in CI.

With multiple per-package configs, relying on auto-discovery can be fragile. Consider passing --config vitest.config.ts so this job always uses the root workspace definition; please verify the flag is supported in Vitest 3.2.4.

🔧 Suggested change
-      - run: pnpm vitest run
+      - run: pnpm vitest run --config vitest.config.ts
🤖 Fix all issues with AI agents
In @.github/workflows/test-template.yml:
- Around line 1094-1097: The Vitest Unit Tests step is missing the explicit
config flag used by the main Vitest job; update the step that runs "pnpm vitest
run" (job name "Vitest Unit Tests") to include the same explicit Vitest config
flag (for example --config=vitest.config.ts) so macOS/Windows use the identical
project set, and verify that the chosen flag is supported by Vitest 3.2.4 before
committing.

In `@packages/client-common/vitest.config.ts`:
- Around line 1-7: Add a brief doc comment above the exported Vitest
configuration (the export default defineConfig({...}) block) explaining that
this is the package-specific Vitest config and why 'dist/*' is excluded (to
avoid running tests against built artifacts/compiled output). Place the comment
immediately above the export so it documents the exported config, referencing
the test.exclude setting that appends 'dist/*' to configDefaults.exclude.

In `@packages/client-generator-registry/vitest.config.ts`:
- Around line 1-7: Add a short doc comment above the exported Vitest
configuration (the default export created via defineConfig in vitest.config.ts)
that explains this is the package-specific Vitest config and explicitly states
why 'dist/*' is excluded (to avoid running tests against compiled/distributed
files); update the comment to reference that exclude merges with
configDefaults.exclude and that excluding 'dist/*' prevents duplicate/irrelevant
test runs from build artifacts.

In `@packages/dmmf/vitest.config.ts`:
- Around line 1-7: Add a brief doc comment above the exported default Vitest
config (the defineConfig export in this file) describing that this is the
package-specific Vitest configuration and explicitly noting why 'dist/*' is
added to the test.exclude list (to avoid running tests against
compiled/distributed artifacts). Update the comment to reference the exported
symbol (the default export from defineConfig) and mention the rationale for
excluding 'dist/*' so it satisfies the coding guideline requiring doc comments
for exported items.

In `@packages/ts-builders/vitest.config.ts`:
- Around line 1-7: Add a brief doc comment above the exported Vitest config (the
default export created via defineConfig) that describes this package-specific
test configuration and explicitly notes why 'dist/*' is excluded (to avoid
running tests against built artifacts/compiled output). Place the comment
immediately above the defineConfig(...) export and mention the test.exclude
setting so reviewers understand the intent.

In `@vitest.config.ts`:
- Around line 1-18: Add a JSDoc comment describing the exported Vitest
configuration object returned by defineConfig (the default export) that explains
its purpose and notes the use of test.projects with glob negation (e.g.,
'!packages/cli') as the intended multi-project setup; place the JSDoc
immediately above the export/default defineConfig call and include a brief
summary plus any relevant tags (e.g., `@returns` or `@see`) to satisfy the coding
guideline for exported items.

Comment thread .github/workflows/test-template.yml Resolved
Comment thread packages/client-common/vitest.config.ts Resolved
Comment on lines +1 to +7
import { configDefaults, defineConfig } from 'vitest/config'

export default defineConfig({
test: {
exclude: [...configDefaults.exclude, 'dist/*'],
},
})

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.

🧹 Nitpick | 🔵 Trivial

Add a doc comment for the exported config.

Please add a brief doc comment explaining the package-specific Vitest config and why dist/* is excluded.

✍️ Proposed doc comment
+/**
+ * Package-local Vitest config; excludes built artifacts from test discovery.
+ */
 export default defineConfig({
   test: {
     exclude: [...configDefaults.exclude, 'dist/*'],
   },
 })

As per coding guidelines, exported items should have doc comments.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { configDefaults, defineConfig } from 'vitest/config'
export default defineConfig({
test: {
exclude: [...configDefaults.exclude, 'dist/*'],
},
})
import { configDefaults, defineConfig } from 'vitest/config'
/**
* Package-local Vitest config; excludes built artifacts from test discovery.
*/
export default defineConfig({
test: {
exclude: [...configDefaults.exclude, 'dist/*'],
},
})
🤖 Prompt for AI Agents
In `@packages/dmmf/vitest.config.ts` around lines 1 - 7, Add a brief doc comment
above the exported default Vitest config (the defineConfig export in this file)
describing that this is the package-specific Vitest configuration and explicitly
noting why 'dist/*' is added to the test.exclude list (to avoid running tests
against compiled/distributed artifacts). Update the comment to reference the
exported symbol (the default export from defineConfig) and mention the rationale
for excluding 'dist/*' so it satisfies the coding guideline requiring doc
comments for exported items.

Comment thread packages/ts-builders/vitest.config.ts Resolved
Comment thread vitest.config.ts Resolved
@dulmandakh

Copy link
Copy Markdown
Contributor Author

@aqrln @jacek-prisma please review and let's merge this before #29032

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@packages/credentials-store/package.json`:
- Around line 29-31: Update the devDependency "tempy" in package.json from
"1.0.1" to "3.1.0" (edit the devDependencies entry for "tempy") and regenerate
the lockfile by running your package manager (npm/yarn/pnpm install) so the
updated version is recorded; ensure tests still pass and update any import/usage
if the newer tempy API requires minor adjustments in the codebase.

Comment on lines 29 to 31
"devDependencies": {
"tempy": "1.0.1",
"vitest": "3.2.4"
"tempy": "1.0.1"
},

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.

🧹 Nitpick | 🔵 Trivial

🧩 Analysis chain

🌐 Web query:

tempy npm latest version and compatibility

💡 Result:

Latest npm version: 3.1.0 (published ~2 years ago). [1][2]

Node compatibility: tempy@3.1.0 requires Node.js >= 14.16.0 (package engines). [3]

Install: npm install tempy. [1]

Sources:

  • npm package page (tempy 3.1.0). [1]
  • Snyk package summary (latest 3.1.0). [2]
  • package-lock / registry metadata showing "engines": "node": ">=14.16". [3]

🏁 Script executed:

# Find root package.json to check Node/runtime constraints
find . -maxdepth 2 -name "package.json" -type f | head -5

Repository: prisma/prisma

Length of output: 71


🏁 Script executed:

# Check for .nvmrc or node version specifications
git ls-files | grep -E "(\\.nvmrc|\\.(tool-versions|node-version)|package\\.json)"

Repository: prisma/prisma

Length of output: 12647


🏁 Script executed:

# Read root package.json to check Node version constraints
cat ./package.json | head -50

Repository: prisma/prisma

Length of output: 2120


🏁 Script executed:

# Read the full credentials-store package.json to see how tempy is used
cat ./packages/credentials-store/package.json

Repository: prisma/prisma

Length of output: 983


🏁 Script executed:

# Search for tempy usage in credentials-store package
rg "tempy" packages/credentials-store --type ts --type js --type json -B 2 -A 2

Repository: prisma/prisma

Length of output: 1084


🌐 Web query:

tempy npm package changelog breaking changes version 1.0.1 to 3.1.0

💡 Result:

Do you want me to fetch the package's GitHub/npm release notes and list every breaking change between 1.0.1 and 3.1.0? (I'll look up and cite the sources.)


🌐 Web query:

tempy 1.0.1 breaking changes security issues npm

💡 Result:

Short answer: There are no widely reported breaking changes or security vulnerabilities specifically tied to tempy@1.0.1 in public advisories. Public package scans (ReversingLabs / Spectra, Snyk) and npm package metadata show no known vulnerabilities for tempy, and the package's changelogs/releases do not list a breaking-change notice for a 1.0.1 release. [1][2][3]

Sources:

  • npm package info / versions for tempy. [1]
  • ReversingLabs Spectra Assure scan (no known vulnerabilities found). [2]
  • Snyk / general vulnerability tracking for temp-like packages (no active advisories for tempy). [3]

If you want, I can:

  • fetch the tempy GitHub release/CHANGELOG and quote the exact 1.0.1 entry, or
  • run a fresh security scan of a specific tarball or version you care about.

🌐 Web query:

tempy package GitHub releases 3.0.0 2.0.0 breaking changes

💡 Result:

Do you mean the npm package "tempy" (sindresorhus/tempy)? If so I can fetch the GitHub release notes and list the breaking changes between v2.0.0 and v3.0.0 — shall I look them up now?


Update tempy to the latest version (3.1.0) for better maintenance.

While tempy 1.0.1 is compatible with the repository's Node version requirement (20.19+), it is significantly outdated. The latest version 3.1.0 has no reported breaking changes and should be a safe upgrade for this test utility.

🤖 Prompt for AI Agents
In `@packages/credentials-store/package.json` around lines 29 - 31, Update the
devDependency "tempy" in package.json from "1.0.1" to "3.1.0" (edit the
devDependencies entry for "tempy") and regenerate the lockfile by running your
package manager (npm/yarn/pnpm install) so the updated version is recorded;
ensure tests still pass and update any import/usage if the newer tempy API
requires minor adjustments in the codebase.

@aqrln aqrln added this to the 7.3.0 milestone Jan 17, 2026
@codspeed

codspeed Bot commented Jan 17, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 98.39%

❌ 1 regressed benchmark
✅ 40 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ compile findUnique simple 900.5 µs 56,101.6 µs -98.39%

Comparing dulmandakh:vitest-consolidate-execution (f5d0485) with main (223b6ea)

Open in CodSpeed

@dulmandakh

Copy link
Copy Markdown
Contributor Author

@aqrln please review and approve workflow

@aqrln aqrln modified the milestones: 7.3.0, 7.4.0 Jan 28, 2026
@jacek-prisma

Copy link
Copy Markdown
Contributor

I approved the workflows, looks like there's a number of failing jobs

@dulmandakh

Copy link
Copy Markdown
Contributor Author

closing in favor of #29142

@dulmandakh dulmandakh closed this Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants