Conversation
📝 WalkthroughWalkthroughThis pull request sets up Vitest as a test framework for the UI package by introducing test scripts, adding Vitest as a development dependency, creating a Vitest configuration file, and updating ESLint to recognize the configuration file. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
ui/vitest.config.ts (1)
5-7: Considerglobals: trueif migrating from Jest.Without it, every test file must explicitly import
describe,it,expect, andvifromvitest. That's idiomatic Vitest and fine for a greenfield setup, but addingglobals: truemakes the transition easier for contributors accustomed to Jest's auto-global style.💡 Optional: enable test globals
test: { environment: "node", + globals: true, },🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ui/vitest.config.ts` around lines 5 - 7, The Vitest config's test block currently sets environment: "node" but doesn't enable Jest-like auto-globals, so add globals: true to the test configuration object (the "test" config in vitest.config.ts) to allow describe/it/expect/vi to be available without importing them; update the test config entry (the object containing environment: "node") to include globals: true alongside the existing settings.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@ui/vitest.config.ts`:
- Around line 5-7: The Vitest config's test block currently sets environment:
"node" but doesn't enable Jest-like auto-globals, so add globals: true to the
test configuration object (the "test" config in vitest.config.ts) to allow
describe/it/expect/vi to be available without importing them; update the test
config entry (the object containing environment: "node") to include globals:
true alongside the existing settings.
What changed
Installed vitest to dev-dependencies
npm i -D vitestAdded scripts to package.json (
--passWithNoTestsallows the script to succeed even if no tests have been added yet)Added
ui/vitest.config.tsfile for @alias mapping and Node.js test environmentAdded
vitest.config.tsto ..eslintrcignoreExports to suppress lint warning for default exportHow to use
Run all tests:
cd ui && npm run testRun in watch mode:
cd ui && npm run test:watchTest file naming Vitest discovers by default:
*.test.ts,*.test.tsx,*.spec.ts,*.spec.tsxPlace tests close to source (recommended), e.g.:
utils/dataTransforms.tsutils/dataTransforms.test.tsCurrent config uses environment: "node":
Summary by CodeRabbit