Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: vitest workspaces #998

Merged
merged 8 commits into from
May 1, 2024
Merged

Conversation

kanadgupta
Copy link
Member

@kanadgupta kanadgupta commented May 1, 2024

🧰 Changes

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 #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 reports1
  • Easier to share options between the two configs
  • A single config file to rule them all
  • Tests seem to be faster (but hard to say)

🧬 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

Footnotes

  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.

@kanadgupta kanadgupta added the enhancement New feature or request label May 1, 2024
@kanadgupta kanadgupta requested a review from erunion May 1, 2024 14:35
@kanadgupta kanadgupta marked this pull request as ready for review May 1, 2024 14:35
@kanadgupta kanadgupta merged commit 1713d6b into next May 1, 2024
9 checks passed
@kanadgupta kanadgupta deleted the kanad-2024-05-01/vitest-workspaces branch May 1, 2024 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants