[!IMPORTANT]
this continues to be a vitest supremacy account π€
In this repo, we have tests that use process.chdir(), so we maintain a separate Vitest config for running those via a forks pool vs. the standard threads pool β see https://github.com/readmeio/rdme/pull/870 for more background on this.
We've used two separate npm scripts (i.e., npm run test:multi && npm run test:single) to run our tests sequentially. I discovered this morning that Vitest's workspaces feature isn't just for monorepos β it's actually the recommended way to maintain multiple test configurations no matter the context.
In this PR, I consolidated our two test configs into a single workspace config. We get a few nice benefits by leveraging workspaces:
No longer needing to manually pass in the correct config file when running certain test files (e.g., npx vitest --config vitest.single-threaded.config.ts [file]). In other words, npx vitest [file] β¨ just works β¨, which should make it a lot easier for new contributors to run tests
Much cleaner test output β we now can see coverage across all files, rather than two separate coverage reports[^1]
π§° Changes
In this repo, we have tests that use
process.chdir()
, so we maintain a separate Vitest config for running those via aforks
pool vs. the standardthreads
pool β see https://github.com/readmeio/rdme/pull/870 for more background on this.We've used two separate npm scripts (i.e.,
npm run test:multi && npm run test:single
) to run our tests sequentially. I discovered this morning that Vitest's workspaces feature isn't just for monorepos β it's actually the recommended way to maintain multiple test configurations no matter the context.In this PR, I consolidated our two test configs into a single workspace config. We get a few nice benefits by leveraging workspaces:
npx vitest --config vitest.single-threaded.config.ts [file]
). In other words,npx vitest [file]
β¨ just works β¨, which should make it a lot easier for new contributors to run tests𧬠QA & Testing
Do all the tests run? And do they still run and pass properly? Here's the latest test run in
next
for comparison: https://github.com/readmeio/rdme/actions/runs/8910638856[^1]: Small downside to this β workspaces don't allow you to configure coverage options. Not a huge deal since our coverage is great in this repo and we can stick to the defaults and it still addresses our needs.