Skip to content

test: speed up prisma script tests and merge --bun script tests - #1150

Merged
exKAZUu merged 3 commits into
mainfrom
exKAZUu/speed-up-tests
Jul 30, 2026
Merged

test: speed up prisma script tests and merge --bun script tests#1150
exKAZUu merged 3 commits into
mainfrom
exKAZUu/speed-up-tests

Conversation

@exKAZUu

@exKAZUu exKAZUu commented Jul 30, 2026

Copy link
Copy Markdown
Member

Customer Summary

  • No user-visible behavior changes: this only speeds up the automated test suite.
  • CI and local verification runs finish faster, shortening feedback for every future change.

Technical Summary

  • packages/wb/test/unit/scripts/prismaScripts.test.ts (~29s → ~3s under vitest):
    • Create SQLite fixtures with node:sqlite (DatabaseSync, still a real WAL-mode database) instead of spawning npx prisma db execute per fixture, closing connections via try...finally.
    • Verify the checkpointed database directly with node:sqlite instead of a prisma db pull introspection.
    • The one remaining real Prisma invocation (executing the generated cleanUpLitestream command, the behavior under test) now runs via bunx with CHECKPOINT_DISABLE=1, skipping the telemetry network call that dominated CLI startup (~12s → ~4s per spawn locally).
  • packages/wbfy/test/unit/packageJson.test.ts: merged the three bun --bun rewrite tests (identical config, disjoint script names) into a single generatePackageJson call; the run-target/script-name relationships the tests rely on (build exists → alias, server absent → file) are preserved.

Why

  • The prismaScripts test file dominated the wb package's test time, and almost all of it was Prisma CLI startup and telemetry overhead rather than the behavior under test.
  • Measured per-file timings across all packages first; the remaining slow file (wbfy/test/unit/packageJson.test.ts, ~40s) is dominated by one-time synchronous npm show <dep> version registry lookups in the generator (warm generatePackageJson calls take ~10ms), so further test merging there would not reduce runtime. Speeding that up would need parallelized/batched version lookups in wbfy itself — left as a possible follow-up.
  • Other slow tests (cleanupIdempotency, maintenanceCommand, typecheck, setup) are genuine E2E flows and were left untouched.

Testing

  • bun verify-full passed (typecheck + lint + all tests; tests 1m 1s).
  • bun vitest run test/unit/scripts/prismaScripts.test.ts in packages/wb: 5 passed in ~3s.
  • bun vitest run test/unit/packageJson.test.ts in packages/wbfy: 81 passed.

🤖 Generated with Claude Code

Create SQLite fixtures with node:sqlite instead of spawning the Prisma
CLI, keep the single real Prisma invocation on bunx with telemetry
disabled, and merge the three `bun --bun` rewrite tests into one
generator call. Cuts the wb prismaScripts test file from ~29s to ~5s.

Co-authored-by: WillBooster (Claude Code) <agent@willbooster.com>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on improving the performance of the test suite by eliminating redundant external process calls and consolidating overlapping test cases. By leveraging native Node.js SQLite capabilities and suppressing unnecessary network calls in the Prisma CLI, the build pipeline sees a meaningful reduction in total test duration.

Highlights

  • Prisma Test Optimization: Replaced expensive Prisma CLI spawns with native node:sqlite database operations, reducing test execution time from ~29s to ~5s.
  • CLI Telemetry Suppression: Disabled Prisma CLI telemetry via CHECKPOINT_DISABLE=1 to significantly reduce startup latency for remaining CLI invocations.
  • Test Suite Consolidation: Merged multiple bun --bun rewrite tests in wbfy into a single, more efficient test case.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.


Tests were slow and took their time, Running Prisma, quite a crime. Now with SQLite, fast and lean, The test suite runs like a machine.

Footnotes

  1. Review the Generative AI Prohibited Use Policy, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request replaces slow Prisma CLI invocations with Node's native DatabaseSync from node:sqlite in the Prisma script unit tests, and optimizes the test environment by disabling Prisma telemetry. It also consolidates and expands the test cases for stripping bun --bun from package.json scripts. The review feedback suggests wrapping the DatabaseSync operations in try...finally blocks to guarantee that database connections are properly closed even if errors occur during execution.

Comment thread packages/wb/test/unit/scripts/prismaScripts.test.ts Outdated
Comment thread packages/wb/test/unit/scripts/prismaScripts.test.ts Outdated
@exKAZUu

exKAZUu commented Jul 30, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request optimizes the Prisma script tests in the wb package by replacing slow Prisma CLI invocations with direct SQLite operations using DatabaseSync, switching the test command to bunx, and disabling Prisma telemetry. Additionally, it consolidates several test cases in wbfy related to stripping bun --bun from package scripts. There are no review comments, and I have no feedback to provide.

@exKAZUu exKAZUu self-assigned this Jul 30, 2026
@exKAZUu
exKAZUu merged commit c4efaee into main Jul 30, 2026
5 checks passed
@exKAZUu
exKAZUu deleted the exKAZUu/speed-up-tests branch July 30, 2026 14:08
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.

1 participant