Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
uses: actions/upload-artifact@v7
with:
name: blob-report-${{ github.run_id }}-${{ matrix.shardIndex }}
path: '.vitest-reports/*'
path: '.vitest/blob/*'
include-hidden-files: true
retention-days: 1

Expand Down Expand Up @@ -135,7 +135,7 @@ jobs:
- name: Download coverage reports
uses: actions/download-artifact@v8
with:
path: .vitest-reports
path: .vitest/blob
pattern: blob-report-${{ github.run_id }}-*
merge-multiple: true
- name: Merge coverage reports
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ lib-cov
coverage
*.lcov

# Vitest blob reports
.vitest-reports
# Vitest reports and attachments
.vitest

# nyc test coverage
.nyc_output
Expand Down
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ Note on **knip**: in-file usage keeps an exported type "used" (`ignoreExportsUse

## Testing

The monorepo uses [Vitest v4](https://vitest.dev) for testing.
The monorepo uses [Vitest v5](https://vitest.dev) for testing.

### Running Tests

Expand Down Expand Up @@ -307,6 +307,7 @@ Use numeric separators (`30_000` instead of `30000`) for readability.
- Snapshots are generated with `pnpm test -u`
- Root Vitest sets `SC_DISABLE_SPEEDY=false` so styled-components keeps its fast CSSOM injection path under jsdom (upstream disables it when `NODE_ENV !== 'production'`, which makes first mounts of styled-heavy trees slow enough to trip default timeouts). Same approach as [sanity#13675](https://github.com/sanity-io/sanity/pull/13675).
- For plugins that use vanilla-extract: register `vanillaExtractPlugin()` in the plugin’s `vitest.config.ts` (required so `.css.ts` compiles under Vitest) and include `'@vanilla-extract/css/disableRuntimeStyles'` in `setupFiles` (no-op under `node`, skips CSS injection for `jsdom`/`happy-dom` suites; remove only when a test asserts real CSS) — see the `sanity-plugin-best-practices` styling reference (`Disabling runtime styles in tests`)
- For suites that use `@testing-library/jest-dom`: register its matchers in the setup file with `expect.extend(matchers)` from `@testing-library/jest-dom/matchers`, and get their types from `/// <reference types="@testing-library/jest-dom/vitest" />` (see `plugins/@sanity/presets/src/test/setup.ts`), as sanity-io/ui does. Don't import the `@testing-library/jest-dom/vitest` entry: it extends whichever vitest pnpm links next to jest-dom, which can be a different copy than the one running the tests.

## Pull Request Workflow

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Type checking is [performed by oxlint](https://oxc.rs/blog/2025-12-08-type-aware

### Testing

The monorepo uses [Vitest v4](https://vitest.dev) for testing.
The monorepo uses [Vitest v5](https://vitest.dev) for testing.

```bash
# Run all tests (non-watch mode)
Expand Down
2 changes: 1 addition & 1 deletion dev/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@types/react-dom": "catalog:",
"@vanilla-extract/css": "catalog:",
"@vitejs/plugin-react": "^6.1.2",
"@vitest/browser-playwright": "^4.1.11",
"@vitest/browser-playwright": "^5.0.5",
"oxc-transform-react": "catalog:",
"playwright": "^1.63.0",
"react": "catalog:",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import * as _jestDom from '@testing-library/jest-dom/vitest'
/// <reference types="@testing-library/jest-dom/vitest" />

import * as matchers from '@testing-library/jest-dom/matchers'
import {expect} from 'vitest'

// Not `@testing-library/jest-dom/vitest`: that entry extends whichever vitest
// pnpm links next to jest-dom, which can be a different copy than the one
// running the tests.
expect.extend(matchers)

// Mock window.matchMedia for @sanity/ui components
Object.defineProperty(window, 'matchMedia', {
Expand Down
10 changes: 9 additions & 1 deletion plugins/@sanity/language-filter/src/test/setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import * as _jestDom from '@testing-library/jest-dom/vitest'
/// <reference types="@testing-library/jest-dom/vitest" />

import * as matchers from '@testing-library/jest-dom/matchers'
import {expect} from 'vitest'

// Not `@testing-library/jest-dom/vitest`: that entry extends whichever vitest
// pnpm links next to jest-dom, which can be a different copy than the one
// running the tests.
expect.extend(matchers)

// Mock window.matchMedia for @sanity/ui components
Object.defineProperty(window, 'matchMedia', {
Expand Down
10 changes: 9 additions & 1 deletion plugins/@sanity/presets/src/test/setup.ts
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
import * as _jestDom from '@testing-library/jest-dom/vitest'
/// <reference types="@testing-library/jest-dom/vitest" />

import * as matchers from '@testing-library/jest-dom/matchers'
import {expect} from 'vitest'

// Not `@testing-library/jest-dom/vitest`: that entry extends whichever vitest
// pnpm links next to jest-dom, which can be a different copy than the one
// running the tests.
expect.extend(matchers)
10 changes: 9 additions & 1 deletion plugins/@sanity/studio-secrets/src/test/setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import * as _jestDom from '@testing-library/jest-dom/vitest'
/// <reference types="@testing-library/jest-dom/vitest" />

import * as matchers from '@testing-library/jest-dom/matchers'
import {expect} from 'vitest'

// Not `@testing-library/jest-dom/vitest`: that entry extends whichever vitest
// pnpm links next to jest-dom, which can be a different copy than the one
// running the tests.
expect.extend(matchers)

// Mock window.matchMedia for @sanity/ui components
Object.defineProperty(window, 'matchMedia', {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import * as _jestDom from '@testing-library/jest-dom/vitest'
/// <reference types="@testing-library/jest-dom/vitest" />

import * as matchers from '@testing-library/jest-dom/matchers'
import {expect} from 'vitest'

// Not `@testing-library/jest-dom/vitest`: that entry extends whichever vitest
// pnpm links next to jest-dom, which can be a different copy than the one
// running the tests.
expect.extend(matchers)

// Mock window.matchMedia for @sanity/ui components
Object.defineProperty(window, 'matchMedia', {
Expand Down
12 changes: 9 additions & 3 deletions plugins/sanity-plugin-media/vitest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
// oxlint-disable-next-line import/no-unassigned-import
import '@testing-library/jest-dom/vitest'
import {vi} from 'vitest'
/// <reference types="@testing-library/jest-dom/vitest" />

import * as matchers from '@testing-library/jest-dom/matchers'
import {expect, vi} from 'vitest'

// Not `@testing-library/jest-dom/vitest`: that entry extends whichever vitest
// pnpm links next to jest-dom, which can be a different copy than the one
// running the tests.
expect.extend(matchers)

if (typeof window !== 'undefined') {
Object.defineProperty(window, 'matchMedia', {
Expand Down
Loading
Loading