From 0685b6f027576589464fc6109ddc071ef0079f16 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Thu, 19 Mar 2026 14:10:12 +0100 Subject: [PATCH] test: don't generate `results.json` file in inlined tests (#9714) --- test/cli/test/reporters/import-durations.test.ts | 5 +++-- test/cli/test/watch/file-watching.test.ts | 9 ++++++++- test/config/test/cache.test.ts | 6 ++++++ test/test-utils/index.ts | 1 + 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/test/cli/test/reporters/import-durations.test.ts b/test/cli/test/reporters/import-durations.test.ts index 5cce634d2..19aea1f7c 100644 --- a/test/cli/test/reporters/import-durations.test.ts +++ b/test/cli/test/reporters/import-durations.test.ts @@ -30,13 +30,14 @@ describe('import durations', () => { const root = resolve(import.meta.dirname, '..', '..', 'fixtures', 'reporters') it('should populate importDurations on File with import durations during execution', async () => { - const { exitCode, ctx, stderr } = await runVitest({ + const { ctx, stderr } = await runVitest({ root, include: ['**/import-durations.test.ts'], experimental: { importDurations: { limit: 10 } }, }) - expect(exitCode, `Expected exit code 0 but got ${exitCode}. stderr: ${stderr}`).toBe(0) + expect(stderr).toBe('') + expect(ctx?.state.errorsSet).toHaveLength(0) const capturedFiles = ctx!.state.getFiles() diff --git a/test/cli/test/watch/file-watching.test.ts b/test/cli/test/watch/file-watching.test.ts index 88f1defaa..294af56e0 100644 --- a/test/cli/test/watch/file-watching.test.ts +++ b/test/cli/test/watch/file-watching.test.ts @@ -118,7 +118,7 @@ test("dynamic test case", () => { }) test('renaming an existing test file', { retry: 3 }, async () => { - const { vitest, fs } = await testUtils.runInlineTests({ + const { vitest, ctx, fs } = await testUtils.runInlineTests({ 'before.test.js': /* js */` import { expect, test } from "vitest"; @@ -132,10 +132,17 @@ test('renaming an existing test file', { retry: 3 }, async () => { await vitest.waitForStdout('Running existing test') await vitest.waitForStdout('press h to show help') + const fileAdded = new Promise((resolve) => { + ctx!.vite.watcher.on('add', () => { + resolve() + }) + }) + fs.renameFile('before.test.js', 'after.test.js') await vitest.waitForStdout('Test removed') await vitest.waitForStdout('Waiting for file changes...') + await fileAdded vitest.write('p') await vitest.waitForStdout('Input filename pattern') diff --git a/test/config/test/cache.test.ts b/test/config/test/cache.test.ts index c6c3d0202..61e9ac60d 100644 --- a/test/config/test/cache.test.ts +++ b/test/config/test/cache.test.ts @@ -9,6 +9,7 @@ test('default', async () => { const { ctx, stdout, stderr } = await runVitest({ root, include: ['*.test.ts'], + cache: undefined, }) expect(stdout).toContain('✓ basic.test.ts >') @@ -43,6 +44,7 @@ test('use cacheDir', async () => { { root, include: ['*.test.ts'], + cache: undefined, $viteConfig: { cacheDir: 'node_modules/.vite-custom', }, @@ -61,6 +63,7 @@ test('preserves previous test results', async () => { const firstRun = await runVitest({ root, include: ['basic.test.ts'], + cache: undefined, }) expect(firstRun.stdout).toContain('✓ basic.test.ts >') @@ -73,6 +76,7 @@ test('preserves previous test results', async () => { const secondRun = await runVitest({ root, include: ['second.test.ts'], + cache: undefined, }) expect(secondRun.stdout).toContain('✓ second.test.ts >') expect(secondRun.stderr).toBe('') @@ -96,6 +100,7 @@ describe('with optimizer enabled', () => { root, include: ['*.test.ts'], deps, + cache: undefined, }) expect(stdout).toContain('✓ basic.test.ts >') @@ -132,6 +137,7 @@ describe('with optimizer enabled', () => { root, include: ['*.test.ts'], deps, + cache: undefined, $viteConfig: { cacheDir: 'node_modules/.vite-custom', }, diff --git a/test/test-utils/index.ts b/test/test-utils/index.ts index 3997b7577..967c7bafc 100644 --- a/test/test-utils/index.ts +++ b/test/test-utils/index.ts @@ -162,6 +162,7 @@ export async function runVitest( outputJson, mergeReports, clearCache, + cache: 'cache' in config ? config.cache : false, // Test cases are already run with multiple forks/threads maxWorkers: maxWorkers ?? 1, -- 2.51.2