Skip to content

feat(cli): add Vitest as a testing framework option#282

Open
gonzoblasco wants to merge 2 commits into
akd-io:developfrom
gonzoblasco:feature/224-add-vitest-support
Open

feat(cli): add Vitest as a testing framework option#282
gonzoblasco wants to merge 2 commits into
akd-io:developfrom
gonzoblasco:feature/224-add-vitest-support

Conversation

@gonzoblasco

Copy link
Copy Markdown

Add support for Vitest (#224)

Closes #224

Summary

Adds Vitest as a testing framework option via --vitest flag. When enabled, the generated project includes Vitest as a devDependency, test scripts, and a vitest.config.ts file.

Changes

  • New plugin vitest.ts with:
    • vitest@^4.0.0 as devDependency (matching the version used internally by create-next-stack itself)
    • Scripts: test (vitest run), test:watch (vitest), test:ci (vitest run --reporter=verbose)
    • vitest.config.ts generated with defineConfig and environment: "node"
    • Technology metadata for README and landing page
  • CLI flag: --vitest (boolean)
  • Plugin registration: vitestPlugin added to setup.ts
  • Sort orders: vitest added to technologies, test:watch and test:ci added to scripts

Why

Vitest is the modern standard for testing in Vite-powered Next.js projects. Notably, create-next-stack itself already uses Vitest internally for its own test suite, but did not offer it as an option in the scaffold. This PR closes that gap.

Verification

  • pnpm run build — clean
  • pnpm run lint — no errors
  • pnpm run unit — 9/9 tests pass
  • ./bin/run --help shows --vitest flag

Notes

  • Vitest v4 is used to match the version used internally by create-next-stack.
  • The generated vitest.config.ts uses environment: "node" as a sensible default. Users can customize it for DOM testing (jsdom/happy-dom) as needed.
  • Website (create-next-stack.com) is NOT updated in this PR — can be done in a follow-up.

- Add vitest plugin with devDep, scripts (test, test:watch, test:ci), and vitest.config.ts
- Add --vitest flag to CLI
- Register vitestPlugin in setup
- Add vitest to technologies sort order
- Add test:watch and test:ci to scripts sort order
@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown

@gonzoblasco is attempting to deploy a commit to the 9ty Team on Vercel.

A member of the Team first needs to authorize it.

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.

Add support for Vitest

1 participant