Skip to content
Merged
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
15 changes: 15 additions & 0 deletions packages/@sanity/cli/test/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,18 @@ import {vi} from 'vitest'
*/
// Mock open, to prevent it from opening a browser
vi.mock('open')

// `@oclif/core/lib/screen.js` reads `process.stdout.getWindowSize()` at module
// init when `process.stdout.isTTY` is truthy. Vitest's stdout proxy doesn't
// implement `getWindowSize`, so any test that flips `isTTY = true` before oclif
// is loaded (e.g. `checkForUpdates.test.ts`) crashes the whole worker.
// Provide a no-op shim once per worker so the eventual load is safe.
for (const stream of [process.stdout, process.stderr] as const) {
if (typeof stream.getWindowSize !== 'function') {
Object.defineProperty(stream, 'getWindowSize', {
configurable: true,
value: () => [80, 24],
writable: true,
})
}
}
Loading