Skip to content

Adrian/add test runner (vitest)#994

Open
adrmac wants to merge 2 commits intomainfrom
adrian/add-test-runner
Open

Adrian/add test runner (vitest)#994
adrmac wants to merge 2 commits intomainfrom
adrian/add-test-runner

Conversation

@adrmac
Copy link
Member

@adrmac adrmac commented Feb 21, 2026

What changed

  1. Installed vitest to dev-dependencies
    npm i -D vitest

  2. Added scripts to package.json (--passWithNoTests allows the script to succeed even if no tests have been added yet)

    "test": "vitest run --passWithNoTests",
    "test:watch": "vitest --passWithNoTests"
  1. Added ui/vitest.config.ts file for @alias mapping and Node.js test environment

  2. Added vitest.config.ts to ..eslintrc ignoreExports to suppress lint warning for default export

How to use

Run all tests:
cd ui && npm run test

Run in watch mode:
cd ui && npm run test:watch

Test file naming Vitest discovers by default:
*.test.ts, *.test.tsx, *.spec.ts, *.spec.tsx

Place tests close to source (recommended), e.g.:
utils/dataTransforms.ts
utils/dataTransforms.test.ts

Current config uses environment: "node":

  • Best for pure utilities/transforms
  • Use "jsdom" if you add DOM/component tests

Summary by CodeRabbit

  • Chores
    • Introduced testing framework and configuration to support automated testing
    • Added test scripts for running tests in standard and watch modes
    • Updated development tooling configuration to accommodate new testing infrastructure

@adrmac adrmac requested a review from paulcretu as a code owner February 21, 2026 00:32
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 21, 2026

📝 Walkthrough

Walkthrough

This 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

Cohort / File(s) Summary
ESLint Configuration
ui/.eslintrc
Added vitest.config.ts to the ignoreExports list to exclude it from unused module checks.
Package Configuration
ui/package.json
Added test and test:watch scripts, included Vitest as a devDependency, and updated the prepare script formatting.
Vitest Setup
ui/vitest.config.ts
New configuration file establishing Vitest with Node test environment and module path alias @ pointing to ui/src directory.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Hops of joy for tests so true,
Vitest setup, fresh and new!
Aliases mapped, configs laid,
Testing foundations now displayed! 🧪✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding Vitest as a test runner to the project, which is confirmed by all changes (config file, package.json, ESLint rules).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch adrian/add-test-runner

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@paulcretu paulcretu temporarily deployed to orcasite-pr-994 February 21, 2026 00:35 Inactive
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
ui/vitest.config.ts (1)

5-7: Consider globals: true if migrating from Jest.

Without it, every test file must explicitly import describe, it, expect, and vi from vitest. That's idiomatic Vitest and fine for a greenfield setup, but adding globals: true makes 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.

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