Skip to content

chore: jest -> vitest /editor - #492

Merged
softmarshmallow merged 1 commit into
mainfrom
canary
Jan 12, 2026
Merged

softmarshmallow merged 1 commit into
mainfrom
canary

Conversation

@softmarshmallow

@softmarshmallow softmarshmallow commented Jan 12, 2026 •

Copy link
Copy Markdown
Member
  • Tests

    • Migrated automated test suite from Jest to Vitest for faster execution
    • Removed mocked modules to ensure tests validate actual implementation behavior
  • Chores

    • Updated test infrastructure configuration and dependencies
    • Added explicit conditional exports (TypeScript types, ESM, CommonJS) to grida-canvas-cg package

…est configurations, and remove unused Jest files
@vercel

vercel Bot commented Jan 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
backgrounds Ready Ready Preview, Comment Jan 12, 2026 7:14am
blog Ready Ready Preview, Comment Jan 12, 2026 7:14am
docs Ready Ready Preview, Comment Jan 12, 2026 7:14am
grida Ready Ready Preview, Comment Jan 12, 2026 7:14am
viewer Ready Ready Preview, Comment Jan 12, 2026 7:14am
2 Skipped Deployments
Project Deployment Review Updated (UTC)
code Ignored Ignored Jan 12, 2026 7:14am
legacy Ignored Ignored Jan 12, 2026 7:14am

@coderabbitai

coderabbitai Bot commented Jan 12, 2026 •

Copy link
Copy Markdown

Walkthrough

This pull request migrates the editor package's test framework from Jest to Vitest. Changes include deleting Jest configuration, removing Jest-specific mocks and setup code, adding Vitest configuration, updating test scripts and dependencies in package.json, and adding explicit conditional exports to grida-canvas-cg's package.json.

Changes

Cohort / File(s) Summary
Test Framework Migration - Configuration
editor/jest.config.js, editor/jest.setup.ts, editor/vitest.config.ts, editor/package.json
Removed Jest Next.js wrapper configuration, deleted ESM module mocks (svg-pathdata), introduced Vitest configuration with root, alias, and test globals setup; updated test script from "jest" to "vitest run" and removed Jest/jsdom dependencies.
Test Setup Cleanup
editor/grida-canvas-utils/css.test.ts, editor/grida-canvas/reducers/__tests__/image-paint-clipboard.test.ts, editor/grida-canvas/reducers/__tests__/vector-cut.test.ts
Removed Jest module mocks for @grida/cmath, color-name, and surface.reducer, eliminating virtual module stubs and mock isolation patterns.
Test Updates for Vitest
editor/grida-canvas/reducers/__tests__/history.test.ts, editor/grida-canvas/reducers/__tests__/vector-self-remove.test.ts
Replaced jest.spyOn with vi.spyOn syntax; adjusted Date.now mock timestamps (1000/1200 → 1000/1401) and merge-window assertions; expanded document structure, state initialization, and vector node setup to use real grida editor state instead of inline mocks.
Package Exports
packages/grida-canvas-cg/package.json
Added explicit exports field with conditional export mappings for types (\.d.ts), ESM import (\.mjs), and CommonJS require (\*.js) entry points.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • [Ops] Fix tests #336: Modifies Jest configuration and test mocks for ESM-only modules (svg-pathdata), directly related to test setup migration.

Poem

🐰 From Jest to Vitest, we bounce with glee,
Mocks fade away, real tests run free,
Config files deleted, new paths take flight,
Our tests run faster—oh what a sight! ✨

🚥 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 PR title accurately describes the main change: migrating the test framework from Jest to Vitest in the /editor directory.
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
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch canary

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
editor/grida-canvas/reducers/__tests__/vector-self-remove.test.ts (1)

38-38: Type assertion masks potentially missing required fields.

The satisfies Partial<...> as any pattern suggests the test node is missing required fields from VectorNode. While acceptable for test scaffolding, consider adding the missing fields (e.g., fill, stroke_width, etc.) to avoid potential runtime issues if the reducer starts validating node completeness.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 984df25 and 17c04c6.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • editor/grida-canvas-utils/css.test.ts
  • editor/grida-canvas/reducers/__tests__/history.test.ts
  • editor/grida-canvas/reducers/__tests__/image-paint-clipboard.test.ts
  • editor/grida-canvas/reducers/__tests__/vector-cut.test.ts
  • editor/grida-canvas/reducers/__tests__/vector-self-remove.test.ts
  • editor/jest.config.js
  • editor/jest.setup.ts
  • editor/package.json
  • editor/vitest.config.ts
  • packages/grida-canvas-cg/package.json
💤 Files with no reviewable changes (5)
  • editor/grida-canvas/reducers/tests/image-paint-clipboard.test.ts
  • editor/grida-canvas-utils/css.test.ts
  • editor/grida-canvas/reducers/tests/vector-cut.test.ts
  • editor/jest.setup.ts
  • editor/jest.config.js
🧰 Additional context used
🧠 Learnings (5)
📚 Learning: 2025-12-01T00:22:41.045Z
Learnt from: CR
Repo: gridaco/grida PR: 0
File: editor/AGENTS.md:0-0
Timestamp: 2025-12-01T00:22:41.045Z
Learning: Applies to editor/**/next-env.d.ts : Include `next-env.d.ts` file in git for the project to avoid requiring dev/build runs for typechecking in CI environments

Applied to files:

  • editor/vitest.config.ts
  • editor/package.json
📚 Learning: 2025-12-01T00:22:56.899Z
Learnt from: CR
Repo: gridaco/grida PR: 0
File: editor/app/(tools)/tools/halftone/AGENTS.md:0-0
Timestamp: 2025-12-01T00:22:56.899Z
Learning: Applies to editor/app/(tools)/tools/halftone/app/(tools)/tools/halftone/_page.tsx : For SVG export, convert circles to <circle> elements, rectangles to <rect> elements, and polygons to <polygon> elements with calculated points

Applied to files:

  • editor/grida-canvas/reducers/__tests__/vector-self-remove.test.ts
📚 Learning: 2025-12-01T00:22:56.899Z
Learnt from: CR
Repo: gridaco/grida PR: 0
File: editor/app/(tools)/tools/halftone/AGENTS.md:0-0
Timestamp: 2025-12-01T00:22:56.899Z
Learning: Applies to editor/app/(tools)/tools/halftone/app/(tools)/tools/halftone/_page.tsx : When adding new shape types, update the Shape type union, add cases in drawShape() function, add cases in shapeToSVG() function, and add SelectItem in UI

Applied to files:

  • editor/grida-canvas/reducers/__tests__/vector-self-remove.test.ts
📚 Learning: 2025-12-01T00:22:19.083Z
Learnt from: CR
Repo: gridaco/grida PR: 0
File: crates/grida-canvas-wasm/AGENTS.md:0-0
Timestamp: 2025-12-01T00:22:19.083Z
Learning: Applies to crates/grida-canvas-wasm/**/main.rs : Update `grida-canvas-wasm.d.ts` TypeScript definitions file when new APIs are introduced via `main.rs`

Applied to files:

  • packages/grida-canvas-cg/package.json
📚 Learning: 2025-12-01T00:22:19.083Z
Learnt from: CR
Repo: gridaco/grida PR: 0
File: crates/grida-canvas-wasm/AGENTS.md:0-0
Timestamp: 2025-12-01T00:22:19.083Z
Learning: Applies to crates/grida-canvas-wasm/**/+(grida-canvas-wasm.js|grida-canvas-wasm.wasm) : Include WASM artifacts (`grida-canvas-wasm.js` and `grida-canvas-wasm.wasm`) in git for faster CI builds

Applied to files:

  • packages/grida-canvas-cg/package.json
🧬 Code graph analysis (1)
editor/grida-canvas/reducers/__tests__/vector-self-remove.test.ts (1)
editor/grida-canvas/editor.ts (3)
  • state (331-333)
  • state (2685-2687)
  • state (3882-3884)
🔇 Additional comments (6)
packages/grida-canvas-cg/package.json (1)

25-31: LGTM!

The conditional exports field is correctly structured with proper ordering (types → import → require) and aligns with the existing main/module/types fields. This ensures proper module resolution for both ESM and CJS consumers, which is particularly helpful for Vitest's module resolution.

editor/grida-canvas/reducers/__tests__/history.test.ts (2)

7-7: LGTM!

The explicit import of vi from Vitest is a good practice even with globals: true, as it provides better IDE support and makes the dependency clear.


278-287: Timing adjustment aligns with merge window logic.

The change from 1200ms to 1401ms (401ms gap instead of 200ms) correctly tests that actions outside the 300ms merge window create separate history entries. The test now properly validates the boundary condition.

editor/grida-canvas/reducers/__tests__/vector-self-remove.test.ts (1)

53-63: State construction looks correct for the test scenario.

The test properly initializes state via editor.state.init() and adds test-specific overrides. The gesture: { type: "idle" } and initial_vector_network additions align with the expected state structure for content edit mode exit.

editor/vitest.config.ts (1)

11-18: No changes needed to the vitest configuration.

The test suite consists of unit tests (canvas operations, reducers, utilities, expressions) that do not interact with the DOM. Although @testing-library/react appears in devDependencies, it is not used in any test files. The default Node.js environment is appropriate for this project's testing needs.

Likely an incorrect or invalid review comment.

editor/package.json (1)

12-12: No changes needed. The test script vitest run works correctly—vitest is provided by the workspace root in this pnpm monorepo and is accessible to the editor package. The current setup is valid.

This branch was successfully deployed

5 active deployments
Preview – grida — 17c04c6c Deployed Jan 12, 2026 by vercel[bot]
Preview – docs — 17c04c6c Deployed Jan 12, 2026 by vercel[bot]
Preview – backgrounds — 17c04c6c Deployed Jan 12, 2026 by vercel[bot]
Preview – viewer — 17c04c6c Deployed Jan 12, 2026 by vercel[bot]
Preview – blog — 17c04c6c Deployed Jan 12, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant