Skip to content

Conversation

BarryThePenguin
Copy link
Contributor

Using vitest projects to reduce the configuration required for tests

Comment on lines 18 to -26
needs:
- main
- bun
- fastly
- node
- deno
- workerd
- lambda
- lambda-edge
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only need to collect coverage from the main, bun, and deno jobs as bun run test will include coverage for the each of fastly, node, workerd, lambda, and lambda-edge

Comment on lines -10 to -15
include: ['**/runtime-tests/fastly/**/(*.)+(test).+(ts|tsx)'],
exclude: ['**/runtime-tests/fastly/vitest.config.ts'],
coverage: {
...config.test?.coverage,
reportsDirectory: './coverage/raw/runtime-fastly',
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Project configuration is simpler as test files are found relative to the vitest.config.ts, while coverage configuration remains in the root vitest.config.ts

],
"scripts": {
"test": "tsc --noEmit && vitest --run && vitest -c .vitest.config/jsx-runtime-default.ts --run && vitest -c .vitest.config/jsx-runtime-dom.ts --run",
"test": "tsc --noEmit && vitest --run",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vitest --run will run all projects, including all runtime tests.

The equivalent command for just the jsx runtime tests would be..

vitest --project jsx-runtime-default --project jsx-runtime-dom --run

},
pool: 'forks',
projects: [
'./runtime-tests/*/vitest.config.ts',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will lookup and run all the runtime tests

Comment on lines 27 to 43
{
esbuild: {
jsx: 'automatic',
jsxImportSource: './src/jsx',
},
extends: true,
test: {
environment: 'node',
exclude: [...configDefaults.exclude, 'src/jsx', '**/*.case.test.*'],
include: [
'src/**/(*.)+(spec|test).+(ts|tsx|js)',
'scripts/**/(*.)+(spec|test).+(ts|tsx|js)',
'build/**/(*.)+(spec|test).+(ts|tsx|js)',
],
name: 'unit',
},
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will run the same tests as what vitest --run previously ran

Comment on lines +44 to +54
{
esbuild: {
jsx: 'automatic',
jsxImportSource: './src/jsx',
},
extends: true,
test: {
include: ['src/jsx/dom/**/(*.)+(spec|test).+(ts|tsx|js)', 'src/jsx/hooks/dom.test.tsx'],
name: 'jsx-runtime-default',
},
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This runs the same tests as what vitest -c .vitest.config/jsx-runtime-default.ts --run previously ran

Comment on lines +55 to +65
{
esbuild: {
jsx: 'automatic',
jsxImportSource: './src/jsx/dom',
},
extends: true,
test: {
include: ['src/jsx/dom/**/(*.)+(spec|test).+(ts|tsx|js)', 'src/jsx/hooks/dom.test.tsx'],
name: 'jsx-runtime-dom',
},
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This runs the same tests as what vitest -c .vitest.config/jsx-runtime-dom.ts --run previously ran

Copy link

codecov bot commented Aug 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.31%. Comparing base (117d0a4) to head (5e7b310).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4359      +/-   ##
==========================================
- Coverage   91.34%   91.31%   -0.04%     
==========================================
  Files         172      171       -1     
  Lines       10934    10894      -40     
  Branches     3134     3137       +3     
==========================================
- Hits         9988     9948      -40     
  Misses        945      945              
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@yusukebe
Copy link
Member

@BarryThePenguin

Awesome! This is a good improvement for the repo. Thanks!

@yusukebe yusukebe merged commit d1c072a into honojs:main Aug 20, 2025
20 checks passed
@BarryThePenguin BarryThePenguin deleted the tests/vitest-projects branch August 20, 2025 10:28
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.

2 participants