Improve testing story by migrating to vite/vitest? #492
ThisIsMissEm
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Proposal
Swap
osprey_ui's build and test tooling from rsbuild/rstest to Vite/Vitest.Raising this as a discussion rather than an issue because #235 was maintainer-directed ("@haileyok @cmttt is this what you had in mind?") and the reasoning for rsbuild over the alternatives isn't recorded anywhere I can find. If there was a reason, I'd rather hear it than quietly migrate away from it.
What's actually driving this: the frontend has no test story
The build tool is close to a coin flip. The test runner isn't.
pnpm testrunsrstest --passWithNoTests, soui-qualityis structurally incapable of failing on coverage. It reads as a passing test job to anyone glancing at the checks.src/components/event_stream/getSummaryFeaturesForEvent.test.ts, a pure-function test. No component tests, no e2e, no testing-library, no jsdom, no msw.@types/jest@24.0.23is still in devDependencies — jest types, from 2019, with no jest installed and a different runner in use. Anyone writing their first test will be autocompleted toward globals that don't exist.This is about to matter more. The rule-authoring UI (#403, backed by #487) renders differently depending on
can_edit_rules,can_deploy_rulesandrule_deployment_enabled, across threeRuleStatusvalues. Those branches currently have no way to be verified except a human deliberately becoming each kind of user and looking.Why Vitest specifically
@rstest/corevitestrstest is fifteen months old and pre-1.0. For rendering components and asserting on permission-dependent UI, Vitest's testing-library/jsdom story is four years old and exhaustively documented, where rstest's is new enough that we'd be debugging the runner alongside our own tests. With one test file in the repo, there is nothing to migrate and no sunk cost.
It also has a path beyond unit tests. Vitest's Browser Mode runs tests in a real browser (Playwright or WebdriverIO as the provider) rather than jsdom, which is the right level for "does the deploy dialog disable the button for an author" — and full E2E is Playwright, sharing the same Vite pipeline and config. Vitest doesn't claim to be an E2E tool itself, but the Vite ecosystem gives a continuous path from unit → component-in-browser → E2E. I couldn't find an equivalent story for rstest.
Why the bundler comes along
Vitest doesn't require Vite as the app bundler, so we could keep rsbuild and add Vitest. The argument for moving both is consistency: coop already uses Vite, and one toolchain across ROOST projects means contributors move between repos without relearning. That's worth more than either tool's benchmarks.
It also happens to be cheap, because there is no webpack lineage to preserve. #235 replaced
react-scripts(create-react-app), not a hand-rolled webpack config, andrsbuild.config.tsis 25 lines that map 1:1 onto Vite:pluginReact()@vitejs/plugin-reactpluginSass()sass)server.host/server.portloadEnv({ prefixes: ['REACT_APP_'] })envPrefix: 'REACT_APP_'source.define: { 'process.env': … }define— identical shimhtml.template: './public/index.html'index.htmlmoves to project rootoutput.distPath.root: 'build'build.outDir: 'build'No custom loaders, no aliases, no webpack plugins. I also checked the source for webpack-isms that would block an ESM-first bundler —
require.context,require(),module.hot,!!loader!syntax, SVG-as-component imports, CommonJS — and there are none. Threeprocess.env.reads, which thedefineshim above already covers.Rough shape of the work
@rsbuild/*withvite,@vitejs/plugin-react,sasspublic/index.htmlto the project root, add<script type="module" src="/src/index.tsx">rstest→vitest; drop--passWithNoTestsonce there is something to run@types/jest@testing-library/react+jsdomand one real component test, so the check can failReasons not to
What I'd like from this discussion
Mainly: was rsbuild chosen for a reason that isn't written down? And if not, is aligning on Vite/Vitest with coop something we want, or would you rather keep the bundler and just fix the testing gap?
Related: #219 (SDLC checklist — "Tests for all commits" is unticked), #304, #302.
All reactions