From dafba6a386f0cedf5e676a7bcf1bf5f1c0d39040 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 22 Mar 2026 03:22:44 +0000 Subject: [PATCH 1/6] fix: resolve `retry.condition` RegExp serialization issue --- .../src/client/public/esm-client-injector.js | 3 +++ packages/browser/src/node/project.ts | 16 ++++++++----- test/browser/specs/retry-condition.test.ts | 23 +++++++++++++++++++ test/core/test/retry-condition.test.ts | 21 +++++++++++++++++ 4 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 test/browser/specs/retry-condition.test.ts diff --git a/packages/browser/src/client/public/esm-client-injector.js b/packages/browser/src/client/public/esm-client-injector.js index def79a213264..051d394d3a95 100644 --- a/packages/browser/src/client/public/esm-client-injector.js +++ b/packages/browser/src/client/public/esm-client-injector.js @@ -50,6 +50,9 @@ if (config.testNamePattern) config.testNamePattern = parseRegexp(config.testNamePattern); + if (config.retry?.condition) + config.retry.condition = parseRegexp(config.retry.condition); + function parseRegexp(input) { // Parse input const m = input.match(/(\/?)(.+)\1([a-z]*)/i); diff --git a/packages/browser/src/node/project.ts b/packages/browser/src/node/project.ts index bbc6f32860b0..77bd7878ad82 100644 --- a/packages/browser/src/node/project.ts +++ b/packages/browser/src/node/project.ts @@ -129,11 +129,15 @@ export class ProjectBrowser implements IProjectBrowser { } function wrapConfig(config: SerializedConfig): SerializedConfig { - return { - ...config, - // workaround RegExp serialization - testNamePattern: config.testNamePattern - ? (config.testNamePattern.toString() as any as RegExp) - : undefined, + config = { ...config } + + // workaround RegExp serialization + config.testNamePattern &&= config.testNamePattern.toString() as any as RegExp + + // workaround RegExp serialization + if (typeof config.retry === 'object') { + config.retry.condition &&= config.retry.condition.toString() as any as RegExp } + + return config } diff --git a/test/browser/specs/retry-condition.test.ts b/test/browser/specs/retry-condition.test.ts new file mode 100644 index 000000000000..5cc7d4f69188 --- /dev/null +++ b/test/browser/specs/retry-condition.test.ts @@ -0,0 +1,23 @@ +import { expect, test } from 'vitest' +import { runInlineBrowserTests } from './utils' + +test('test.retry.condition is corrrectly serialized', async () => { + const { stderr, results } = await runInlineBrowserTests({ + 'basic.test.js': /* js */` + import { expect, test } from 'vitest' + + test('task.retry.condition is corrrectly deserialized', ({ task }) => { + expect(task.retry.condition).toBeInstanceOf(RegExp) + expect(task.retry.condition).toStrictEqual(/retry_this/) + }) + `, + }, { + retry: { + condition: /retry_this/, + }, + }) + expect(stderr).toBe('') + for (const result of results) { + expect(result.state()).toBe('passed') + } +}) diff --git a/test/core/test/retry-condition.test.ts b/test/core/test/retry-condition.test.ts index 0269c8f771fd..4728cd4fc9df 100644 --- a/test/core/test/retry-condition.test.ts +++ b/test/core/test/retry-condition.test.ts @@ -1,5 +1,6 @@ import type { TestError } from 'vitest' import { describe, expect, it } from 'vitest' +import { runInlineTests } from '../../test-utils' // Test with RegExp condition that eventually passes let matchingCount = 0 @@ -69,3 +70,23 @@ describe('retry condition with describe', { // Second attempt succeeds }) }) + +it('test.retry.condition is corrrectly serialized', async () => { + const { stderr, results } = await runInlineTests({ + 'basic.test.js': /* js */` + import { expect, test } from 'vitest' + + test('task.retry.condition is corrrectly deserialized', ({ task }) => { + expect(task.retry.condition).toBeInstanceOf(RegExp) + expect(task.retry.condition).toStrictEqual(/retry_this/) + }) + `, + }, { + retry: { + condition: /retry_this/, + }, + }) + expect(stderr).toBe('') + expect(results).toHaveLength(1) + expect(results[0].state()).toBe('passed') +}) From 97b79aa40a0e192aeb6fc03917beacbb7260fd84 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 22 Mar 2026 18:23:09 +0000 Subject: [PATCH 2/6] move test --- test/cli/test/retry-condition.test.ts | 22 ++++++++++++++++++++++ test/core/test/retry-condition.test.ts | 21 --------------------- 2 files changed, 22 insertions(+), 21 deletions(-) create mode 100644 test/cli/test/retry-condition.test.ts diff --git a/test/cli/test/retry-condition.test.ts b/test/cli/test/retry-condition.test.ts new file mode 100644 index 000000000000..cdd16b707f15 --- /dev/null +++ b/test/cli/test/retry-condition.test.ts @@ -0,0 +1,22 @@ +import { runInlineTests } from '#test-utils' +import { expect, it } from 'vitest' + +it('test.retry.condition is corrrectly serialized', async () => { + const { stderr, results } = await runInlineTests({ + 'basic.test.js': /* js */` + import { expect, test } from 'vitest' + + test('task.retry.condition is corrrectly deserialized', ({ task }) => { + expect(task.retry.condition).toBeInstanceOf(RegExp) + expect(task.retry.condition).toStrictEqual(/retry_this/) + }) + `, + }, { + retry: { + condition: /retry_this/, + }, + }) + expect(stderr).toBe('') + expect(results).toHaveLength(1) + expect(results[0].state()).toBe('passed') +}) diff --git a/test/core/test/retry-condition.test.ts b/test/core/test/retry-condition.test.ts index 4728cd4fc9df..0269c8f771fd 100644 --- a/test/core/test/retry-condition.test.ts +++ b/test/core/test/retry-condition.test.ts @@ -1,6 +1,5 @@ import type { TestError } from 'vitest' import { describe, expect, it } from 'vitest' -import { runInlineTests } from '../../test-utils' // Test with RegExp condition that eventually passes let matchingCount = 0 @@ -70,23 +69,3 @@ describe('retry condition with describe', { // Second attempt succeeds }) }) - -it('test.retry.condition is corrrectly serialized', async () => { - const { stderr, results } = await runInlineTests({ - 'basic.test.js': /* js */` - import { expect, test } from 'vitest' - - test('task.retry.condition is corrrectly deserialized', ({ task }) => { - expect(task.retry.condition).toBeInstanceOf(RegExp) - expect(task.retry.condition).toStrictEqual(/retry_this/) - }) - `, - }, { - retry: { - condition: /retry_this/, - }, - }) - expect(stderr).toBe('') - expect(results).toHaveLength(1) - expect(results[0].state()).toBe('passed') -}) From 79be2ab8e1b90d3bcc203fff452c7c837789a3b8 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 22 Mar 2026 18:35:14 +0000 Subject: [PATCH 3/6] consistent `#test-utils` import --- test/cli/test/annotations.test.ts | 2 +- test/cli/test/around-each.test.ts | 2 +- test/cli/test/artifacts.test.ts | 2 +- test/cli/test/assertion-helper.test.ts | 2 +- test/cli/test/bail-race.test.ts | 2 +- test/cli/test/benchmarking.test.ts | 2 +- test/cli/test/browser-multiple.test.ts | 3 +-- test/cli/test/caching.test.ts | 2 +- test/cli/test/concurrent.test.ts | 2 +- test/cli/test/config-loader.test.ts | 2 +- test/cli/test/config/passWithNoTests.test.ts | 2 +- test/cli/test/console.test.ts | 2 +- test/cli/test/custom-pool.test.ts | 2 +- test/cli/test/custom-runner.test.ts | 2 +- test/cli/test/detect-async-leaks.test.ts | 2 +- test/cli/test/dotted-files.test.ts | 2 +- test/cli/test/expect-soft.test.ts | 2 +- test/cli/test/expect-task.test.ts | 2 +- test/cli/test/fails.test.ts | 3 +-- test/cli/test/git-changed.test.ts | 4 ++-- test/cli/test/global-setup.test.ts | 3 +-- test/cli/test/group-order.test.ts | 2 +- test/cli/test/init.test.ts | 2 +- test/cli/test/inspect.test.ts | 3 +-- test/cli/test/list.test.ts | 2 +- test/cli/test/location-filters.test.ts | 2 +- test/cli/test/mocking.test.ts | 4 ++-- test/cli/test/network-imports.test.ts | 2 +- test/cli/test/no-unexpected-logging.test.ts | 2 +- test/cli/test/open-telemetry.test.ts | 2 +- test/cli/test/optimize-deps.test.ts | 2 +- test/cli/test/path-filter.test.ts | 2 +- test/cli/test/plugin.test.ts | 2 +- test/cli/test/print-error.test.ts | 2 +- test/cli/test/public-api.test.ts | 2 +- test/cli/test/reported-tasks.test.ts | 2 +- test/cli/test/restricted-fs.test.ts | 3 +-- test/cli/test/retry-clear-mocks.test.ts | 2 +- test/cli/test/run-custom-env.test.ts | 3 +-- test/cli/test/scoped-fixtures.test.ts | 4 ++-- test/cli/test/server-url.test.ts | 3 +-- test/cli/test/setup-files.test.ts | 2 +- test/cli/test/shared-env.test.ts | 2 +- test/cli/test/signal.test.ts | 2 +- test/cli/test/skip-note.test.ts | 2 +- test/cli/test/ssr-runner.test.ts | 2 +- test/cli/test/stacktraces.test.ts | 2 +- test/cli/test/standalone.test.ts | 2 +- test/cli/test/test-specifications.test.ts | 2 +- test/cli/test/tty.test.ts | 2 +- test/cli/test/unhandled-ignore.test.ts | 2 +- test/cli/test/vm-threads.test.ts | 3 +-- test/cli/test/windows-drive-case.test.ts | 2 +- 53 files changed, 56 insertions(+), 64 deletions(-) diff --git a/test/cli/test/annotations.test.ts b/test/cli/test/annotations.test.ts index dabb7c4b6d8f..8027665fbcd4 100644 --- a/test/cli/test/annotations.test.ts +++ b/test/cli/test/annotations.test.ts @@ -1,8 +1,8 @@ import type { TestArtifact } from '@vitest/runner' import type { TestAnnotation } from 'vitest' +import { runInlineTests } from '#test-utils' import { playwright } from '@vitest/browser-playwright' import { describe, expect, test } from 'vitest' -import { runInlineTests } from '../../test-utils' const test3Content = /* ts */` export async function externalAnnotate(annotate) { diff --git a/test/cli/test/around-each.test.ts b/test/cli/test/around-each.test.ts index fff738ef7e12..377388b18ae9 100644 --- a/test/cli/test/around-each.test.ts +++ b/test/cli/test/around-each.test.ts @@ -1,5 +1,5 @@ +import { runInlineTests } from '#test-utils' import { expect, test } from 'vitest' -import { runInlineTests } from '../../test-utils' function extractLogs(stdout: string): string { return stdout.split('\n').filter(l => l.includes('>>')).join('\n') diff --git a/test/cli/test/artifacts.test.ts b/test/cli/test/artifacts.test.ts index 6ecfc22f55ad..d6442ef2d740 100644 --- a/test/cli/test/artifacts.test.ts +++ b/test/cli/test/artifacts.test.ts @@ -1,8 +1,8 @@ import type { TestAnnotation, TestArtifact } from 'vitest' import { format } from 'node:util' +import { runInlineTests } from '#test-utils' import { playwright } from '@vitest/browser-playwright' import { describe, expect, test } from 'vitest' -import { runInlineTests } from '../../test-utils' const test3Content = /* ts */` export async function externalArtifactRecord(recordArtifact, task) { diff --git a/test/cli/test/assertion-helper.test.ts b/test/cli/test/assertion-helper.test.ts index 315d1ad0fec7..5a8c2d57dd4a 100644 --- a/test/cli/test/assertion-helper.test.ts +++ b/test/cli/test/assertion-helper.test.ts @@ -1,6 +1,6 @@ +import { runVitest } from '#test-utils' import { resolve } from 'pathe' import { expect, it } from 'vitest' -import { runVitest } from '../../test-utils' it('assertion helper', async () => { const { stderr, errorTree } = await runVitest({ diff --git a/test/cli/test/bail-race.test.ts b/test/cli/test/bail-race.test.ts index 389f266df98d..bafdf9b814df 100644 --- a/test/cli/test/bail-race.test.ts +++ b/test/cli/test/bail-race.test.ts @@ -1,7 +1,7 @@ +import { StableTestFileOrderSorter } from '#test-utils' import { resolve } from 'pathe' import { expect, onTestFinished, test } from 'vitest' import { createVitest } from 'vitest/node' -import { StableTestFileOrderSorter } from '../../test-utils' test('cancels previous run before starting new one', async () => { const errors: unknown[] = [] diff --git a/test/cli/test/benchmarking.test.ts b/test/cli/test/benchmarking.test.ts index acd0e8457d16..b129b687e78f 100644 --- a/test/cli/test/benchmarking.test.ts +++ b/test/cli/test/benchmarking.test.ts @@ -1,8 +1,8 @@ import type { createBenchmarkJsonReport } from 'vitest/src/node/reporters/benchmark/json-formatter.js' import fs from 'node:fs' +import { runVitest } from '#test-utils' import * as pathe from 'pathe' import { assert, expect, it } from 'vitest' -import { runVitest } from '../../test-utils' it('sequential', async () => { const root = pathe.join(import.meta.dirname, '../fixtures/benchmarking/sequential') diff --git a/test/cli/test/browser-multiple.test.ts b/test/cli/test/browser-multiple.test.ts index ea6c53b2df44..67d576876eee 100644 --- a/test/cli/test/browser-multiple.test.ts +++ b/test/cli/test/browser-multiple.test.ts @@ -1,8 +1,7 @@ import type { Vitest } from 'vitest/node' +import { runVitest } from '#test-utils' import { resolve } from 'pathe' - import { expect, it, onTestFinished, vi } from 'vitest' -import { runVitest } from '../../test-utils' it('automatically assigns the port', async () => { const root = resolve(import.meta.dirname, '../fixtures/browser-multiple') diff --git a/test/cli/test/caching.test.ts b/test/cli/test/caching.test.ts index 8d4c99fcf3f6..a9433c1307b7 100644 --- a/test/cli/test/caching.test.ts +++ b/test/cli/test/caching.test.ts @@ -1,5 +1,5 @@ +import { runVitest, useFS } from '#test-utils' import { expect, test } from 'vitest' -import { runVitest, useFS } from '../../test-utils' test('if file has import.meta.glob, it\'s not cached', async () => { const { createFile } = useFS('./fixtures/caching/import-meta-glob/generated', { diff --git a/test/cli/test/concurrent.test.ts b/test/cli/test/concurrent.test.ts index 80601067a554..a588b38a97fb 100644 --- a/test/cli/test/concurrent.test.ts +++ b/test/cli/test/concurrent.test.ts @@ -1,5 +1,5 @@ +import { runInlineTests } from '#test-utils' import { expect, test } from 'vitest' -import { runInlineTests } from '../../test-utils' // 3 tests depend on each other, // so they will deadlock when maxConcurrency < 3 diff --git a/test/cli/test/config-loader.test.ts b/test/cli/test/config-loader.test.ts index 5a470490e28c..c71683bef9a1 100644 --- a/test/cli/test/config-loader.test.ts +++ b/test/cli/test/config-loader.test.ts @@ -1,5 +1,5 @@ +import { runVitest } from '#test-utils' import { expect, test } from 'vitest' -import { runVitest } from '../../test-utils' const isTypeStrippingSupported = !!process.features.typescript diff --git a/test/cli/test/config/passWithNoTests.test.ts b/test/cli/test/config/passWithNoTests.test.ts index 91ca9ebd950c..f739237cbb2e 100644 --- a/test/cli/test/config/passWithNoTests.test.ts +++ b/test/cli/test/config/passWithNoTests.test.ts @@ -1,5 +1,5 @@ +import { runInlineTests } from '#test-utils' import { expect, it } from 'vitest' -import { runInlineTests } from '../../../test-utils' it('vitest doesnt fail when running empty files', async () => { const { exitCode } = await runInlineTests( diff --git a/test/cli/test/console.test.ts b/test/cli/test/console.test.ts index 777ae4152f1e..d09f99bad21e 100644 --- a/test/cli/test/console.test.ts +++ b/test/cli/test/console.test.ts @@ -1,7 +1,7 @@ +import { runInlineTests, runVitest } from '#test-utils' import { relative, resolve } from 'pathe' import { expect, test } from 'vitest' import { DefaultReporter } from 'vitest/node' -import { runInlineTests, runVitest } from '../../test-utils' test('can run custom pools with Vitest', async () => { const reporter = new DefaultReporter() diff --git a/test/cli/test/custom-pool.test.ts b/test/cli/test/custom-pool.test.ts index 10cb7fb14971..ce820a9def10 100644 --- a/test/cli/test/custom-pool.test.ts +++ b/test/cli/test/custom-pool.test.ts @@ -1,5 +1,5 @@ +import { runVitest } from '#test-utils' import { expect, test } from 'vitest' -import { runVitest } from '../../test-utils' test('can run custom pools with Vitest', async () => { const vitest = await runVitest({ diff --git a/test/cli/test/custom-runner.test.ts b/test/cli/test/custom-runner.test.ts index c95512075ec4..2d06bb40a1e2 100644 --- a/test/cli/test/custom-runner.test.ts +++ b/test/cli/test/custom-runner.test.ts @@ -1,5 +1,5 @@ +import { runVitest } from '#test-utils' import { expect, test } from 'vitest' -import { runVitest } from '../../test-utils' test('extendTaskContext provides correct context.task.suite', async () => { const vitest = await runVitest({ diff --git a/test/cli/test/detect-async-leaks.test.ts b/test/cli/test/detect-async-leaks.test.ts index 934ce486e2ef..924398bde699 100644 --- a/test/cli/test/detect-async-leaks.test.ts +++ b/test/cli/test/detect-async-leaks.test.ts @@ -1,5 +1,5 @@ +import { runInlineTests as base } from '#test-utils' import { expect, test } from 'vitest' -import { runInlineTests as base } from '../../test-utils' test('does not report leaks when disabled', async () => { const { stdout, stderr } = await runInlineTests({ diff --git a/test/cli/test/dotted-files.test.ts b/test/cli/test/dotted-files.test.ts index 8570a6146124..bae111bc6aac 100644 --- a/test/cli/test/dotted-files.test.ts +++ b/test/cli/test/dotted-files.test.ts @@ -1,6 +1,6 @@ import { resolve } from 'node:path' +import { runVitestCli } from '#test-utils' import { expect, it } from 'vitest' -import { runVitestCli } from '../../test-utils' it('run tests even though they are inside the .cache directory', async () => { const { stderr } = await runVitestCli({ diff --git a/test/cli/test/expect-soft.test.ts b/test/cli/test/expect-soft.test.ts index cbc04b8063eb..1ff8a7923be9 100644 --- a/test/cli/test/expect-soft.test.ts +++ b/test/cli/test/expect-soft.test.ts @@ -1,7 +1,7 @@ import type { TestUserConfig } from 'vitest/node' import { resolve } from 'node:path' +import { runVitest } from '#test-utils' import { describe, expect, test, TestRunner } from 'vitest' -import { runVitest } from '../../test-utils' describe('expect.soft', () => { const run = (config?: TestUserConfig) => runVitest({ diff --git a/test/cli/test/expect-task.test.ts b/test/cli/test/expect-task.test.ts index a017bfc5a133..5f01caddf762 100644 --- a/test/cli/test/expect-task.test.ts +++ b/test/cli/test/expect-task.test.ts @@ -1,5 +1,5 @@ +import { runInlineTests } from '#test-utils' import { describe, test } from 'vitest' -import { runInlineTests } from '../../test-utils' const toMatchTest = /* ts */` export function toMatchTest(this, expected) { diff --git a/test/cli/test/fails.test.ts b/test/cli/test/fails.test.ts index 074d3ddc12cd..58d06175e380 100644 --- a/test/cli/test/fails.test.ts +++ b/test/cli/test/fails.test.ts @@ -1,9 +1,8 @@ +import { runInlineTests, runVitest, ts } from '#test-utils' import { playwright } from '@vitest/browser-playwright' - import { resolve } from 'pathe' import { glob } from 'tinyglobby' import { expect, it } from 'vitest' -import { runInlineTests, runVitest, ts } from '../../test-utils' const root = resolve(import.meta.dirname, '../fixtures/fails') const files = await glob(['**/*.test.{ts,js}'], { cwd: root, dot: true, expandDirectories: false }) diff --git a/test/cli/test/git-changed.test.ts b/test/cli/test/git-changed.test.ts index b3ef510df88e..9684e04be4fb 100644 --- a/test/cli/test/git-changed.test.ts +++ b/test/cli/test/git-changed.test.ts @@ -1,7 +1,7 @@ import { join } from 'node:path' -import { describe, expect, it } from 'vitest' +import { createFile, editFile, resolvePath, runVitest } from '#test-utils' -import { createFile, editFile, resolvePath, runVitest } from '../../test-utils' +import { describe, expect, it } from 'vitest' const fileName = 'fixtures/git-changed/related/rerun.temp' diff --git a/test/cli/test/global-setup.test.ts b/test/cli/test/global-setup.test.ts index 97e4e6bd00f5..c9fe5949e9b2 100644 --- a/test/cli/test/global-setup.test.ts +++ b/test/cli/test/global-setup.test.ts @@ -1,8 +1,7 @@ +import { runVitest } from '#test-utils' import { resolve } from 'pathe' import { expect, it } from 'vitest' -import { runVitest } from '../../test-utils' - it('should fail', async () => { const root = resolve(import.meta.dirname, '../fixtures/global-setup-fail') const { stderr } = await runVitest({ root }) diff --git a/test/cli/test/group-order.test.ts b/test/cli/test/group-order.test.ts index 52e8baaa3f96..18a300c58249 100644 --- a/test/cli/test/group-order.test.ts +++ b/test/cli/test/group-order.test.ts @@ -1,5 +1,5 @@ +import { runInlineTests } from '#test-utils' import { expect, test } from 'vitest' -import { runInlineTests } from '../../test-utils' test('tests run according to the group order', async () => { const { stdout, stderr } = await runInlineTests({ diff --git a/test/cli/test/init.test.ts b/test/cli/test/init.test.ts index dc3f725504ee..c8763ef8638e 100644 --- a/test/cli/test/init.test.ts +++ b/test/cli/test/init.test.ts @@ -1,7 +1,7 @@ import { readdir, readFile, rm, writeFile } from 'node:fs/promises' import { join } from 'node:path' +import { runVitestCli } from '#test-utils' import { beforeEach, expect, test } from 'vitest' -import { runVitestCli } from '../../test-utils' const ARROW_DOWN = '\u001B[B' const ENTER = '\n' diff --git a/test/cli/test/inspect.test.ts b/test/cli/test/inspect.test.ts index c244ea4b3f12..fd3f626f2f2e 100644 --- a/test/cli/test/inspect.test.ts +++ b/test/cli/test/inspect.test.ts @@ -1,10 +1,9 @@ import type { InspectorNotification } from 'node:inspector' +import { runVitestCli } from '#test-utils' import { version as viteVersion } from 'vite' import { expect, test } from 'vitest' import WebSocket from 'ws' -import { runVitestCli } from '../../test-utils' - type Message = Partial> test('--inspect-brk stops at test file', async () => { diff --git a/test/cli/test/list.test.ts b/test/cli/test/list.test.ts index e33d4d559640..15312b3d25c2 100644 --- a/test/cli/test/list.test.ts +++ b/test/cli/test/list.test.ts @@ -1,6 +1,6 @@ import { readFileSync, rmSync } from 'node:fs' +import { runVitestCli } from '#test-utils' import { expect, onTestFinished, test } from 'vitest' -import { runVitestCli } from '../../test-utils' test.each([ ['--pool=threads'], diff --git a/test/cli/test/location-filters.test.ts b/test/cli/test/location-filters.test.ts index d1738709637e..66d87c54b11e 100644 --- a/test/cli/test/location-filters.test.ts +++ b/test/cli/test/location-filters.test.ts @@ -1,5 +1,5 @@ +import { runVitestCli } from '#test-utils' import { describe, expect, test } from 'vitest' -import { runVitestCli } from '../../test-utils' const fixturePath = './fixtures/location-filters' diff --git a/test/cli/test/mocking.test.ts b/test/cli/test/mocking.test.ts index 65dea4c0720b..ef147305afc0 100644 --- a/test/cli/test/mocking.test.ts +++ b/test/cli/test/mocking.test.ts @@ -1,11 +1,11 @@ -import type { RunVitestConfig } from '../../test-utils' +import type { RunVitestConfig } from '#test-utils' import { setDefaultResultOrder } from 'node:dns' import path from 'node:path' +import { runInlineTests, runVitest } from '#test-utils' import { playwright } from '@vitest/browser-playwright' import { webdriverio } from '@vitest/browser-webdriverio' import { afterAll, expect, test } from 'vitest' import { rolldownVersion } from 'vitest/node' -import { runInlineTests, runVitest } from '../../test-utils' // webdriver@9 sets dns.setDefaultResultOrder("ipv4first") on import, // which makes Vite resolve localhost to 127.0.0.1 and breaks other tests asserting "localhost" diff --git a/test/cli/test/network-imports.test.ts b/test/cli/test/network-imports.test.ts index 2dba8c0b3c35..bed9dd795959 100644 --- a/test/cli/test/network-imports.test.ts +++ b/test/cli/test/network-imports.test.ts @@ -1,5 +1,5 @@ +import { runVitest } from '#test-utils' import { expect, it } from 'vitest' -import { runVitest } from '../../test-utils' const config = { execArgv: ['--experimental-network-imports'], diff --git a/test/cli/test/no-unexpected-logging.test.ts b/test/cli/test/no-unexpected-logging.test.ts index 735632392fc4..256bde8a8240 100644 --- a/test/cli/test/no-unexpected-logging.test.ts +++ b/test/cli/test/no-unexpected-logging.test.ts @@ -1,5 +1,5 @@ +import { runVitest, StableTestFileOrderSorter } from '#test-utils' import { describe, expect, test } from 'vitest' -import { runVitest, StableTestFileOrderSorter } from '../../test-utils' // Test to detect that there are no unexpected logs, like NodeJS MaxListenersExceededWarning diff --git a/test/cli/test/open-telemetry.test.ts b/test/cli/test/open-telemetry.test.ts index 56b4ebbefa7c..020707547ed5 100644 --- a/test/cli/test/open-telemetry.test.ts +++ b/test/cli/test/open-telemetry.test.ts @@ -1,7 +1,7 @@ import type { TestUserConfig } from 'vitest/node' +import { runVitest } from '#test-utils' import { playwright } from '@vitest/browser-playwright' import { describe, expect, test } from 'vitest' -import { runVitest } from '../../test-utils' describe.for([ 'root', diff --git a/test/cli/test/optimize-deps.test.ts b/test/cli/test/optimize-deps.test.ts index 244268f689f3..7fc26de0feac 100644 --- a/test/cli/test/optimize-deps.test.ts +++ b/test/cli/test/optimize-deps.test.ts @@ -1,5 +1,5 @@ +import { runVitest } from '#test-utils' import { expect, test } from 'vitest' -import { runVitest } from '../../test-utils' test('optimize deps optimizes them into node_modules/.vite', async () => { const { errorTree, stderr } = await runVitest({ diff --git a/test/cli/test/path-filter.test.ts b/test/cli/test/path-filter.test.ts index c2a658a8094c..7b0d4d3f834e 100644 --- a/test/cli/test/path-filter.test.ts +++ b/test/cli/test/path-filter.test.ts @@ -1,5 +1,5 @@ +import { runVitest } from '#test-utils' import { test } from 'vitest' -import { runVitest } from '../../test-utils' test('test path is shown when filtering', async () => { const { vitest } = await runVitest({ diff --git a/test/cli/test/plugin.test.ts b/test/cli/test/plugin.test.ts index 63f72c9a3464..caf66aff9604 100644 --- a/test/cli/test/plugin.test.ts +++ b/test/cli/test/plugin.test.ts @@ -1,5 +1,5 @@ +import { runVitest } from '#test-utils' import { expect, it } from 'vitest' -import { runVitest } from '../../test-utils' it('plugin hooks', async () => { await runVitest({ root: './fixtures/plugin' }) diff --git a/test/cli/test/print-error.test.ts b/test/cli/test/print-error.test.ts index 7b9c16dd60b3..933ed8552500 100644 --- a/test/cli/test/print-error.test.ts +++ b/test/cli/test/print-error.test.ts @@ -1,5 +1,5 @@ +import { runInlineTests } from '#test-utils' import { expect, test } from 'vitest' -import { runInlineTests } from '../../test-utils' test('prints a custom error stack', async () => { const { stderr } = await runInlineTests({ diff --git a/test/cli/test/public-api.test.ts b/test/cli/test/public-api.test.ts index e29bffda7222..33506f5406c7 100644 --- a/test/cli/test/public-api.test.ts +++ b/test/cli/test/public-api.test.ts @@ -1,9 +1,9 @@ import type { TaskMeta } from '@vitest/runner' import type { TestModule, TestUserConfig } from 'vitest/node' +import { runVitest } from '#test-utils' import { resolve } from 'pathe' import { expect, it } from 'vitest' import { rolldownVersion } from 'vitest/node' -import { runVitest } from '../../test-utils' it.each([ { name: 'threads are enabled', pool: 'threads' }, diff --git a/test/cli/test/reported-tasks.test.ts b/test/cli/test/reported-tasks.test.ts index d5248674c291..8e93c9141d30 100644 --- a/test/cli/test/reported-tasks.test.ts +++ b/test/cli/test/reported-tasks.test.ts @@ -1,8 +1,8 @@ import type { RunnerTestFile } from 'vitest' import type { TestCase, TestCollection, TestModule, TestProject, Vitest } from 'vitest/node' +import { runVitest } from '#test-utils' import { resolve } from 'pathe' import { it as baseTest, expect } from 'vitest' -import { runVitest } from '../../test-utils' const root = resolve(__dirname, '..', 'fixtures', 'reported-tasks') diff --git a/test/cli/test/restricted-fs.test.ts b/test/cli/test/restricted-fs.test.ts index 49d89f75085c..82599aa84866 100644 --- a/test/cli/test/restricted-fs.test.ts +++ b/test/cli/test/restricted-fs.test.ts @@ -1,7 +1,6 @@ +import { runVitest } from '#test-utils' import { expect, test } from 'vitest' -import { runVitest } from '../../test-utils' - test('importing files in restricted fs works correctly', async () => { const { stderr, exitCode } = await runVitest({ root: './fixtures/restricted-fs', diff --git a/test/cli/test/retry-clear-mocks.test.ts b/test/cli/test/retry-clear-mocks.test.ts index 64460cdcc1a6..24b7377df597 100644 --- a/test/cli/test/retry-clear-mocks.test.ts +++ b/test/cli/test/retry-clear-mocks.test.ts @@ -1,6 +1,6 @@ import type { TestCase } from 'vitest/node' +import { runInlineTests } from '#test-utils' import { expect, it } from 'vitest' -import { runInlineTests } from '../../test-utils' it('vitest correctly resets mocks between tests', async () => { const { stderr, results } = await runInlineTests({ diff --git a/test/cli/test/run-custom-env.test.ts b/test/cli/test/run-custom-env.test.ts index 382127c859de..409a643bd1e0 100644 --- a/test/cli/test/run-custom-env.test.ts +++ b/test/cli/test/run-custom-env.test.ts @@ -1,8 +1,7 @@ import { createRequire } from 'node:module' +import { runVitest } from '#test-utils' import { expect, test } from 'vitest' -import { runVitest } from '../../test-utils' - test('correctly runs tests if custom env is a file', async () => { const { stderr, exitCode } = await runVitest({ root: './fixtures/custom-file-env', diff --git a/test/cli/test/scoped-fixtures.test.ts b/test/cli/test/scoped-fixtures.test.ts index 65081c75e1af..186fc39b4933 100644 --- a/test/cli/test/scoped-fixtures.test.ts +++ b/test/cli/test/scoped-fixtures.test.ts @@ -1,11 +1,11 @@ +import type { TestFsStructure } from '#test-utils' import type { afterAll, beforeAll, ExpectStatic, expectTypeOf as ExpectTypeOfFn, SuiteAPI, TestAPI } from 'vitest' import type { ViteUserConfig } from 'vitest/config' import type { TestSpecification, TestUserConfig } from 'vitest/node' -import type { TestFsStructure } from '../../test-utils' +import { runInlineTests, stripIndent } from '#test-utils' import { playwright } from '@vitest/browser-playwright' import { beforeEach, describe, expect, test } from 'vitest' import { rolldownVersion } from 'vitest/node' -import { runInlineTests, stripIndent } from '../../test-utils' // "it" is used inside subtests, we can't "import" it because vitest will inject __vite_ssr_import__ declare const it: TestAPI diff --git a/test/cli/test/server-url.test.ts b/test/cli/test/server-url.test.ts index 6e6c092721da..929355aeaec3 100644 --- a/test/cli/test/server-url.test.ts +++ b/test/cli/test/server-url.test.ts @@ -1,8 +1,7 @@ +import { runInlineTests } from '#test-utils' import basicSsl from '@vitejs/plugin-basic-ssl' import { expect, it } from 'vitest' -import { runInlineTests } from '../../test-utils' - it('api server-url http', async () => { const { stdout, stderr } = await runInlineTests( { 'basic.test.js': `test("basic")` }, diff --git a/test/cli/test/setup-files.test.ts b/test/cli/test/setup-files.test.ts index bd320fb7e7da..6a43eb325d3f 100644 --- a/test/cli/test/setup-files.test.ts +++ b/test/cli/test/setup-files.test.ts @@ -1,6 +1,6 @@ import { promises as fs } from 'node:fs' +import { editFile, runVitest } from '#test-utils' import { describe, expect, it, test } from 'vitest' -import { editFile, runVitest } from '../../test-utils' test.each(['threads', 'vmThreads'])('%s: print stdout and stderr correctly when called in the setup file', async (pool) => { const { stdout, stderr } = await runVitest({ diff --git a/test/cli/test/shared-env.test.ts b/test/cli/test/shared-env.test.ts index ea466174ff00..fc5338b225c5 100644 --- a/test/cli/test/shared-env.test.ts +++ b/test/cli/test/shared-env.test.ts @@ -1,5 +1,5 @@ +import { runInlineTests, StableTestFileOrderSorter } from '#test-utils' import { expect, test } from 'vitest' -import { runInlineTests, StableTestFileOrderSorter } from '../../test-utils' test.each([ 1, diff --git a/test/cli/test/signal.test.ts b/test/cli/test/signal.test.ts index ad368addded9..d5a0f884fdb9 100644 --- a/test/cli/test/signal.test.ts +++ b/test/cli/test/signal.test.ts @@ -1,7 +1,7 @@ import type { UserConsoleLog } from 'vitest' import type { Reporter, Vitest } from 'vitest/node' +import { runInlineTests } from '#test-utils' import { expect, test } from 'vitest' -import { runInlineTests } from '../../test-utils' test('timeout aborts the signal without fixtures', async () => { const { stderr, results } = await runInlineTests({ diff --git a/test/cli/test/skip-note.test.ts b/test/cli/test/skip-note.test.ts index 9a3b3efb6705..fbc43d5663c2 100644 --- a/test/cli/test/skip-note.test.ts +++ b/test/cli/test/skip-note.test.ts @@ -1,7 +1,7 @@ import type { TestCase } from 'vitest/node' import { resolve } from 'node:path' +import { runVitest } from '#test-utils' import { expect, test } from 'vitest' -import { runVitest } from '../../test-utils' const root = resolve(import.meta.dirname, '../fixtures/skip-note') diff --git a/test/cli/test/ssr-runner.test.ts b/test/cli/test/ssr-runner.test.ts index cfd71b554dde..4c4653e4119f 100644 --- a/test/cli/test/ssr-runner.test.ts +++ b/test/cli/test/ssr-runner.test.ts @@ -1,6 +1,6 @@ +import { runVitest } from '#test-utils' import { version } from 'vite' import { expect, it } from 'vitest' -import { runVitest } from '../../test-utils' // https://github.com/vitest-dev/vitest/issues/9324 it('ssr runner.import() works in configureServer', async () => { diff --git a/test/cli/test/stacktraces.test.ts b/test/cli/test/stacktraces.test.ts index 4bdcd83960c2..fc4fe52ddb1d 100644 --- a/test/cli/test/stacktraces.test.ts +++ b/test/cli/test/stacktraces.test.ts @@ -1,8 +1,8 @@ +import { runInlineTests, runVitest } from '#test-utils' import { resolve } from 'pathe' import { glob } from 'tinyglobby' import { describe, expect, it } from 'vitest' import { rolldownVersion } from 'vitest/node' -import { runInlineTests, runVitest } from '../../test-utils' // To prevent the warning coming up in snapshots process.setMaxListeners(20) diff --git a/test/cli/test/standalone.test.ts b/test/cli/test/standalone.test.ts index 7f04a9ae7ffa..7df5610bff45 100644 --- a/test/cli/test/standalone.test.ts +++ b/test/cli/test/standalone.test.ts @@ -1,5 +1,5 @@ +import { runVitest } from '#test-utils' import { test } from 'vitest' -import { runVitest } from '../../test-utils' test('test run is not started when --standalone', async () => { const { vitest } = await runVitest({ diff --git a/test/cli/test/test-specifications.test.ts b/test/cli/test/test-specifications.test.ts index f0f745ecccfd..019f653c5050 100644 --- a/test/cli/test/test-specifications.test.ts +++ b/test/cli/test/test-specifications.test.ts @@ -1,6 +1,6 @@ import type { TestSpecificationOptions } from 'vitest/node' +import { runInlineTests } from '#test-utils' import { expect, test } from 'vitest' -import { runInlineTests } from '../../test-utils' test.each( [ diff --git a/test/cli/test/tty.test.ts b/test/cli/test/tty.test.ts index 4df1a84e4864..46b27c71322a 100644 --- a/test/cli/test/tty.test.ts +++ b/test/cli/test/tty.test.ts @@ -1,5 +1,5 @@ +import { runVitestCli } from '#test-utils' import { expect, test } from 'vitest' -import { runVitestCli } from '../../test-utils' test('run mode does not get stuck when TTY', async () => { const { vitest } = await runVitestCli('--root', 'fixtures/tty') diff --git a/test/cli/test/unhandled-ignore.test.ts b/test/cli/test/unhandled-ignore.test.ts index b99439f86787..7adbe07e8a2e 100644 --- a/test/cli/test/unhandled-ignore.test.ts +++ b/test/cli/test/unhandled-ignore.test.ts @@ -1,5 +1,5 @@ +import { runVitest } from '#test-utils' import { expect, test } from 'vitest' -import { runVitest } from '../../test-utils' test('run mode does not get stuck when TTY', async () => { const { vitest } = await runVitest({ diff --git a/test/cli/test/vm-threads.test.ts b/test/cli/test/vm-threads.test.ts index ca69e341a5dc..cfe2199530c2 100644 --- a/test/cli/test/vm-threads.test.ts +++ b/test/cli/test/vm-threads.test.ts @@ -1,7 +1,6 @@ +import { createFile, resolvePath, runInlineTests, runVitest } from '#test-utils' import { expect, test } from 'vitest' -import { createFile, resolvePath, runInlineTests, runVitest } from '../../test-utils' - test('importing files in restricted fs works correctly', async () => { createFile( resolvePath(import.meta.url, '../fixtures/vm-threads/src/external/package-null/package-null.json'), diff --git a/test/cli/test/windows-drive-case.test.ts b/test/cli/test/windows-drive-case.test.ts index 4b44695faa8f..acc8010402db 100644 --- a/test/cli/test/windows-drive-case.test.ts +++ b/test/cli/test/windows-drive-case.test.ts @@ -1,6 +1,6 @@ +import { runVitestCli } from '#test-utils' import { join } from 'pathe' import { expect, test } from 'vitest' -import { runVitestCli } from '../../test-utils' const _DRIVE_LETTER_START_RE = /^[A-Z]:\//i const root = join(import.meta.dirname, '../fixtures/windows-drive-case') From f0a65b9725dce6de77b6d31cbf8610e4f7f96f2f Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 22 Mar 2026 18:43:15 +0000 Subject: [PATCH 4/6] remove newline for consistency --- test/cli/test/git-changed.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/cli/test/git-changed.test.ts b/test/cli/test/git-changed.test.ts index 9684e04be4fb..283a05d9c8c6 100644 --- a/test/cli/test/git-changed.test.ts +++ b/test/cli/test/git-changed.test.ts @@ -1,6 +1,5 @@ import { join } from 'node:path' import { createFile, editFile, resolvePath, runVitest } from '#test-utils' - import { describe, expect, it } from 'vitest' const fileName = 'fixtures/git-changed/related/rerun.temp' From 5e994337d80de2f37c2d6bd095a00abd9156f2e7 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 23 Mar 2026 00:03:48 +0000 Subject: [PATCH 5/6] revert alias import changes --- test/cli/test/annotations.test.ts | 2 +- test/cli/test/around-each.test.ts | 2 +- test/cli/test/artifacts.test.ts | 2 +- test/cli/test/assertion-helper.test.ts | 2 +- test/cli/test/bail-race.test.ts | 2 +- test/cli/test/benchmarking.test.ts | 2 +- test/cli/test/browser-multiple.test.ts | 3 ++- test/cli/test/caching.test.ts | 2 +- test/cli/test/concurrent.test.ts | 2 +- test/cli/test/config-loader.test.ts | 2 +- test/cli/test/config/passWithNoTests.test.ts | 2 +- test/cli/test/console.test.ts | 2 +- test/cli/test/custom-pool.test.ts | 2 +- test/cli/test/custom-runner.test.ts | 2 +- test/cli/test/detect-async-leaks.test.ts | 2 +- test/cli/test/dotted-files.test.ts | 2 +- test/cli/test/expect-soft.test.ts | 2 +- test/cli/test/expect-task.test.ts | 2 +- test/cli/test/fails.test.ts | 3 ++- test/cli/test/git-changed.test.ts | 3 ++- test/cli/test/global-setup.test.ts | 3 ++- test/cli/test/group-order.test.ts | 2 +- test/cli/test/init.test.ts | 2 +- test/cli/test/inspect.test.ts | 3 ++- test/cli/test/list.test.ts | 2 +- test/cli/test/location-filters.test.ts | 2 +- test/cli/test/mocking.test.ts | 4 ++-- test/cli/test/network-imports.test.ts | 2 +- test/cli/test/no-unexpected-logging.test.ts | 2 +- test/cli/test/open-telemetry.test.ts | 2 +- test/cli/test/optimize-deps.test.ts | 2 +- test/cli/test/path-filter.test.ts | 2 +- test/cli/test/plugin.test.ts | 2 +- test/cli/test/print-error.test.ts | 2 +- test/cli/test/public-api.test.ts | 2 +- test/cli/test/reported-tasks.test.ts | 2 +- test/cli/test/restricted-fs.test.ts | 3 ++- test/cli/test/retry-clear-mocks.test.ts | 2 +- test/cli/test/run-custom-env.test.ts | 3 ++- test/cli/test/scoped-fixtures.test.ts | 4 ++-- test/cli/test/server-url.test.ts | 3 ++- test/cli/test/setup-files.test.ts | 2 +- test/cli/test/shared-env.test.ts | 2 +- test/cli/test/signal.test.ts | 2 +- test/cli/test/skip-note.test.ts | 2 +- test/cli/test/ssr-runner.test.ts | 2 +- test/cli/test/stacktraces.test.ts | 2 +- test/cli/test/standalone.test.ts | 2 +- test/cli/test/test-specifications.test.ts | 2 +- test/cli/test/tty.test.ts | 2 +- test/cli/test/unhandled-ignore.test.ts | 2 +- test/cli/test/vm-threads.test.ts | 3 ++- test/cli/test/windows-drive-case.test.ts | 2 +- 53 files changed, 64 insertions(+), 55 deletions(-) diff --git a/test/cli/test/annotations.test.ts b/test/cli/test/annotations.test.ts index 8027665fbcd4..dabb7c4b6d8f 100644 --- a/test/cli/test/annotations.test.ts +++ b/test/cli/test/annotations.test.ts @@ -1,8 +1,8 @@ import type { TestArtifact } from '@vitest/runner' import type { TestAnnotation } from 'vitest' -import { runInlineTests } from '#test-utils' import { playwright } from '@vitest/browser-playwright' import { describe, expect, test } from 'vitest' +import { runInlineTests } from '../../test-utils' const test3Content = /* ts */` export async function externalAnnotate(annotate) { diff --git a/test/cli/test/around-each.test.ts b/test/cli/test/around-each.test.ts index 377388b18ae9..fff738ef7e12 100644 --- a/test/cli/test/around-each.test.ts +++ b/test/cli/test/around-each.test.ts @@ -1,5 +1,5 @@ -import { runInlineTests } from '#test-utils' import { expect, test } from 'vitest' +import { runInlineTests } from '../../test-utils' function extractLogs(stdout: string): string { return stdout.split('\n').filter(l => l.includes('>>')).join('\n') diff --git a/test/cli/test/artifacts.test.ts b/test/cli/test/artifacts.test.ts index d6442ef2d740..6ecfc22f55ad 100644 --- a/test/cli/test/artifacts.test.ts +++ b/test/cli/test/artifacts.test.ts @@ -1,8 +1,8 @@ import type { TestAnnotation, TestArtifact } from 'vitest' import { format } from 'node:util' -import { runInlineTests } from '#test-utils' import { playwright } from '@vitest/browser-playwright' import { describe, expect, test } from 'vitest' +import { runInlineTests } from '../../test-utils' const test3Content = /* ts */` export async function externalArtifactRecord(recordArtifact, task) { diff --git a/test/cli/test/assertion-helper.test.ts b/test/cli/test/assertion-helper.test.ts index 5a8c2d57dd4a..315d1ad0fec7 100644 --- a/test/cli/test/assertion-helper.test.ts +++ b/test/cli/test/assertion-helper.test.ts @@ -1,6 +1,6 @@ -import { runVitest } from '#test-utils' import { resolve } from 'pathe' import { expect, it } from 'vitest' +import { runVitest } from '../../test-utils' it('assertion helper', async () => { const { stderr, errorTree } = await runVitest({ diff --git a/test/cli/test/bail-race.test.ts b/test/cli/test/bail-race.test.ts index bafdf9b814df..389f266df98d 100644 --- a/test/cli/test/bail-race.test.ts +++ b/test/cli/test/bail-race.test.ts @@ -1,7 +1,7 @@ -import { StableTestFileOrderSorter } from '#test-utils' import { resolve } from 'pathe' import { expect, onTestFinished, test } from 'vitest' import { createVitest } from 'vitest/node' +import { StableTestFileOrderSorter } from '../../test-utils' test('cancels previous run before starting new one', async () => { const errors: unknown[] = [] diff --git a/test/cli/test/benchmarking.test.ts b/test/cli/test/benchmarking.test.ts index b129b687e78f..acd0e8457d16 100644 --- a/test/cli/test/benchmarking.test.ts +++ b/test/cli/test/benchmarking.test.ts @@ -1,8 +1,8 @@ import type { createBenchmarkJsonReport } from 'vitest/src/node/reporters/benchmark/json-formatter.js' import fs from 'node:fs' -import { runVitest } from '#test-utils' import * as pathe from 'pathe' import { assert, expect, it } from 'vitest' +import { runVitest } from '../../test-utils' it('sequential', async () => { const root = pathe.join(import.meta.dirname, '../fixtures/benchmarking/sequential') diff --git a/test/cli/test/browser-multiple.test.ts b/test/cli/test/browser-multiple.test.ts index 67d576876eee..ea6c53b2df44 100644 --- a/test/cli/test/browser-multiple.test.ts +++ b/test/cli/test/browser-multiple.test.ts @@ -1,7 +1,8 @@ import type { Vitest } from 'vitest/node' -import { runVitest } from '#test-utils' import { resolve } from 'pathe' + import { expect, it, onTestFinished, vi } from 'vitest' +import { runVitest } from '../../test-utils' it('automatically assigns the port', async () => { const root = resolve(import.meta.dirname, '../fixtures/browser-multiple') diff --git a/test/cli/test/caching.test.ts b/test/cli/test/caching.test.ts index a9433c1307b7..8d4c99fcf3f6 100644 --- a/test/cli/test/caching.test.ts +++ b/test/cli/test/caching.test.ts @@ -1,5 +1,5 @@ -import { runVitest, useFS } from '#test-utils' import { expect, test } from 'vitest' +import { runVitest, useFS } from '../../test-utils' test('if file has import.meta.glob, it\'s not cached', async () => { const { createFile } = useFS('./fixtures/caching/import-meta-glob/generated', { diff --git a/test/cli/test/concurrent.test.ts b/test/cli/test/concurrent.test.ts index a588b38a97fb..80601067a554 100644 --- a/test/cli/test/concurrent.test.ts +++ b/test/cli/test/concurrent.test.ts @@ -1,5 +1,5 @@ -import { runInlineTests } from '#test-utils' import { expect, test } from 'vitest' +import { runInlineTests } from '../../test-utils' // 3 tests depend on each other, // so they will deadlock when maxConcurrency < 3 diff --git a/test/cli/test/config-loader.test.ts b/test/cli/test/config-loader.test.ts index c71683bef9a1..5a470490e28c 100644 --- a/test/cli/test/config-loader.test.ts +++ b/test/cli/test/config-loader.test.ts @@ -1,5 +1,5 @@ -import { runVitest } from '#test-utils' import { expect, test } from 'vitest' +import { runVitest } from '../../test-utils' const isTypeStrippingSupported = !!process.features.typescript diff --git a/test/cli/test/config/passWithNoTests.test.ts b/test/cli/test/config/passWithNoTests.test.ts index f739237cbb2e..91ca9ebd950c 100644 --- a/test/cli/test/config/passWithNoTests.test.ts +++ b/test/cli/test/config/passWithNoTests.test.ts @@ -1,5 +1,5 @@ -import { runInlineTests } from '#test-utils' import { expect, it } from 'vitest' +import { runInlineTests } from '../../../test-utils' it('vitest doesnt fail when running empty files', async () => { const { exitCode } = await runInlineTests( diff --git a/test/cli/test/console.test.ts b/test/cli/test/console.test.ts index d09f99bad21e..777ae4152f1e 100644 --- a/test/cli/test/console.test.ts +++ b/test/cli/test/console.test.ts @@ -1,7 +1,7 @@ -import { runInlineTests, runVitest } from '#test-utils' import { relative, resolve } from 'pathe' import { expect, test } from 'vitest' import { DefaultReporter } from 'vitest/node' +import { runInlineTests, runVitest } from '../../test-utils' test('can run custom pools with Vitest', async () => { const reporter = new DefaultReporter() diff --git a/test/cli/test/custom-pool.test.ts b/test/cli/test/custom-pool.test.ts index ce820a9def10..10cb7fb14971 100644 --- a/test/cli/test/custom-pool.test.ts +++ b/test/cli/test/custom-pool.test.ts @@ -1,5 +1,5 @@ -import { runVitest } from '#test-utils' import { expect, test } from 'vitest' +import { runVitest } from '../../test-utils' test('can run custom pools with Vitest', async () => { const vitest = await runVitest({ diff --git a/test/cli/test/custom-runner.test.ts b/test/cli/test/custom-runner.test.ts index 2d06bb40a1e2..c95512075ec4 100644 --- a/test/cli/test/custom-runner.test.ts +++ b/test/cli/test/custom-runner.test.ts @@ -1,5 +1,5 @@ -import { runVitest } from '#test-utils' import { expect, test } from 'vitest' +import { runVitest } from '../../test-utils' test('extendTaskContext provides correct context.task.suite', async () => { const vitest = await runVitest({ diff --git a/test/cli/test/detect-async-leaks.test.ts b/test/cli/test/detect-async-leaks.test.ts index 924398bde699..934ce486e2ef 100644 --- a/test/cli/test/detect-async-leaks.test.ts +++ b/test/cli/test/detect-async-leaks.test.ts @@ -1,5 +1,5 @@ -import { runInlineTests as base } from '#test-utils' import { expect, test } from 'vitest' +import { runInlineTests as base } from '../../test-utils' test('does not report leaks when disabled', async () => { const { stdout, stderr } = await runInlineTests({ diff --git a/test/cli/test/dotted-files.test.ts b/test/cli/test/dotted-files.test.ts index bae111bc6aac..8570a6146124 100644 --- a/test/cli/test/dotted-files.test.ts +++ b/test/cli/test/dotted-files.test.ts @@ -1,6 +1,6 @@ import { resolve } from 'node:path' -import { runVitestCli } from '#test-utils' import { expect, it } from 'vitest' +import { runVitestCli } from '../../test-utils' it('run tests even though they are inside the .cache directory', async () => { const { stderr } = await runVitestCli({ diff --git a/test/cli/test/expect-soft.test.ts b/test/cli/test/expect-soft.test.ts index 1ff8a7923be9..cbc04b8063eb 100644 --- a/test/cli/test/expect-soft.test.ts +++ b/test/cli/test/expect-soft.test.ts @@ -1,7 +1,7 @@ import type { TestUserConfig } from 'vitest/node' import { resolve } from 'node:path' -import { runVitest } from '#test-utils' import { describe, expect, test, TestRunner } from 'vitest' +import { runVitest } from '../../test-utils' describe('expect.soft', () => { const run = (config?: TestUserConfig) => runVitest({ diff --git a/test/cli/test/expect-task.test.ts b/test/cli/test/expect-task.test.ts index 5f01caddf762..a017bfc5a133 100644 --- a/test/cli/test/expect-task.test.ts +++ b/test/cli/test/expect-task.test.ts @@ -1,5 +1,5 @@ -import { runInlineTests } from '#test-utils' import { describe, test } from 'vitest' +import { runInlineTests } from '../../test-utils' const toMatchTest = /* ts */` export function toMatchTest(this, expected) { diff --git a/test/cli/test/fails.test.ts b/test/cli/test/fails.test.ts index 58d06175e380..074d3ddc12cd 100644 --- a/test/cli/test/fails.test.ts +++ b/test/cli/test/fails.test.ts @@ -1,8 +1,9 @@ -import { runInlineTests, runVitest, ts } from '#test-utils' import { playwright } from '@vitest/browser-playwright' + import { resolve } from 'pathe' import { glob } from 'tinyglobby' import { expect, it } from 'vitest' +import { runInlineTests, runVitest, ts } from '../../test-utils' const root = resolve(import.meta.dirname, '../fixtures/fails') const files = await glob(['**/*.test.{ts,js}'], { cwd: root, dot: true, expandDirectories: false }) diff --git a/test/cli/test/git-changed.test.ts b/test/cli/test/git-changed.test.ts index 283a05d9c8c6..b3ef510df88e 100644 --- a/test/cli/test/git-changed.test.ts +++ b/test/cli/test/git-changed.test.ts @@ -1,7 +1,8 @@ import { join } from 'node:path' -import { createFile, editFile, resolvePath, runVitest } from '#test-utils' import { describe, expect, it } from 'vitest' +import { createFile, editFile, resolvePath, runVitest } from '../../test-utils' + const fileName = 'fixtures/git-changed/related/rerun.temp' // NOTE: if there are any changes in fixtures/git-changed, diff --git a/test/cli/test/global-setup.test.ts b/test/cli/test/global-setup.test.ts index c9fe5949e9b2..97e4e6bd00f5 100644 --- a/test/cli/test/global-setup.test.ts +++ b/test/cli/test/global-setup.test.ts @@ -1,7 +1,8 @@ -import { runVitest } from '#test-utils' import { resolve } from 'pathe' import { expect, it } from 'vitest' +import { runVitest } from '../../test-utils' + it('should fail', async () => { const root = resolve(import.meta.dirname, '../fixtures/global-setup-fail') const { stderr } = await runVitest({ root }) diff --git a/test/cli/test/group-order.test.ts b/test/cli/test/group-order.test.ts index 18a300c58249..52e8baaa3f96 100644 --- a/test/cli/test/group-order.test.ts +++ b/test/cli/test/group-order.test.ts @@ -1,5 +1,5 @@ -import { runInlineTests } from '#test-utils' import { expect, test } from 'vitest' +import { runInlineTests } from '../../test-utils' test('tests run according to the group order', async () => { const { stdout, stderr } = await runInlineTests({ diff --git a/test/cli/test/init.test.ts b/test/cli/test/init.test.ts index c8763ef8638e..dc3f725504ee 100644 --- a/test/cli/test/init.test.ts +++ b/test/cli/test/init.test.ts @@ -1,7 +1,7 @@ import { readdir, readFile, rm, writeFile } from 'node:fs/promises' import { join } from 'node:path' -import { runVitestCli } from '#test-utils' import { beforeEach, expect, test } from 'vitest' +import { runVitestCli } from '../../test-utils' const ARROW_DOWN = '\u001B[B' const ENTER = '\n' diff --git a/test/cli/test/inspect.test.ts b/test/cli/test/inspect.test.ts index fd3f626f2f2e..c244ea4b3f12 100644 --- a/test/cli/test/inspect.test.ts +++ b/test/cli/test/inspect.test.ts @@ -1,9 +1,10 @@ import type { InspectorNotification } from 'node:inspector' -import { runVitestCli } from '#test-utils' import { version as viteVersion } from 'vite' import { expect, test } from 'vitest' import WebSocket from 'ws' +import { runVitestCli } from '../../test-utils' + type Message = Partial> test('--inspect-brk stops at test file', async () => { diff --git a/test/cli/test/list.test.ts b/test/cli/test/list.test.ts index 15312b3d25c2..e33d4d559640 100644 --- a/test/cli/test/list.test.ts +++ b/test/cli/test/list.test.ts @@ -1,6 +1,6 @@ import { readFileSync, rmSync } from 'node:fs' -import { runVitestCli } from '#test-utils' import { expect, onTestFinished, test } from 'vitest' +import { runVitestCli } from '../../test-utils' test.each([ ['--pool=threads'], diff --git a/test/cli/test/location-filters.test.ts b/test/cli/test/location-filters.test.ts index 66d87c54b11e..d1738709637e 100644 --- a/test/cli/test/location-filters.test.ts +++ b/test/cli/test/location-filters.test.ts @@ -1,5 +1,5 @@ -import { runVitestCli } from '#test-utils' import { describe, expect, test } from 'vitest' +import { runVitestCli } from '../../test-utils' const fixturePath = './fixtures/location-filters' diff --git a/test/cli/test/mocking.test.ts b/test/cli/test/mocking.test.ts index ef147305afc0..65dea4c0720b 100644 --- a/test/cli/test/mocking.test.ts +++ b/test/cli/test/mocking.test.ts @@ -1,11 +1,11 @@ -import type { RunVitestConfig } from '#test-utils' +import type { RunVitestConfig } from '../../test-utils' import { setDefaultResultOrder } from 'node:dns' import path from 'node:path' -import { runInlineTests, runVitest } from '#test-utils' import { playwright } from '@vitest/browser-playwright' import { webdriverio } from '@vitest/browser-webdriverio' import { afterAll, expect, test } from 'vitest' import { rolldownVersion } from 'vitest/node' +import { runInlineTests, runVitest } from '../../test-utils' // webdriver@9 sets dns.setDefaultResultOrder("ipv4first") on import, // which makes Vite resolve localhost to 127.0.0.1 and breaks other tests asserting "localhost" diff --git a/test/cli/test/network-imports.test.ts b/test/cli/test/network-imports.test.ts index bed9dd795959..2dba8c0b3c35 100644 --- a/test/cli/test/network-imports.test.ts +++ b/test/cli/test/network-imports.test.ts @@ -1,5 +1,5 @@ -import { runVitest } from '#test-utils' import { expect, it } from 'vitest' +import { runVitest } from '../../test-utils' const config = { execArgv: ['--experimental-network-imports'], diff --git a/test/cli/test/no-unexpected-logging.test.ts b/test/cli/test/no-unexpected-logging.test.ts index 256bde8a8240..735632392fc4 100644 --- a/test/cli/test/no-unexpected-logging.test.ts +++ b/test/cli/test/no-unexpected-logging.test.ts @@ -1,5 +1,5 @@ -import { runVitest, StableTestFileOrderSorter } from '#test-utils' import { describe, expect, test } from 'vitest' +import { runVitest, StableTestFileOrderSorter } from '../../test-utils' // Test to detect that there are no unexpected logs, like NodeJS MaxListenersExceededWarning diff --git a/test/cli/test/open-telemetry.test.ts b/test/cli/test/open-telemetry.test.ts index 020707547ed5..56b4ebbefa7c 100644 --- a/test/cli/test/open-telemetry.test.ts +++ b/test/cli/test/open-telemetry.test.ts @@ -1,7 +1,7 @@ import type { TestUserConfig } from 'vitest/node' -import { runVitest } from '#test-utils' import { playwright } from '@vitest/browser-playwright' import { describe, expect, test } from 'vitest' +import { runVitest } from '../../test-utils' describe.for([ 'root', diff --git a/test/cli/test/optimize-deps.test.ts b/test/cli/test/optimize-deps.test.ts index 7fc26de0feac..244268f689f3 100644 --- a/test/cli/test/optimize-deps.test.ts +++ b/test/cli/test/optimize-deps.test.ts @@ -1,5 +1,5 @@ -import { runVitest } from '#test-utils' import { expect, test } from 'vitest' +import { runVitest } from '../../test-utils' test('optimize deps optimizes them into node_modules/.vite', async () => { const { errorTree, stderr } = await runVitest({ diff --git a/test/cli/test/path-filter.test.ts b/test/cli/test/path-filter.test.ts index 7b0d4d3f834e..c2a658a8094c 100644 --- a/test/cli/test/path-filter.test.ts +++ b/test/cli/test/path-filter.test.ts @@ -1,5 +1,5 @@ -import { runVitest } from '#test-utils' import { test } from 'vitest' +import { runVitest } from '../../test-utils' test('test path is shown when filtering', async () => { const { vitest } = await runVitest({ diff --git a/test/cli/test/plugin.test.ts b/test/cli/test/plugin.test.ts index caf66aff9604..63f72c9a3464 100644 --- a/test/cli/test/plugin.test.ts +++ b/test/cli/test/plugin.test.ts @@ -1,5 +1,5 @@ -import { runVitest } from '#test-utils' import { expect, it } from 'vitest' +import { runVitest } from '../../test-utils' it('plugin hooks', async () => { await runVitest({ root: './fixtures/plugin' }) diff --git a/test/cli/test/print-error.test.ts b/test/cli/test/print-error.test.ts index 933ed8552500..7b9c16dd60b3 100644 --- a/test/cli/test/print-error.test.ts +++ b/test/cli/test/print-error.test.ts @@ -1,5 +1,5 @@ -import { runInlineTests } from '#test-utils' import { expect, test } from 'vitest' +import { runInlineTests } from '../../test-utils' test('prints a custom error stack', async () => { const { stderr } = await runInlineTests({ diff --git a/test/cli/test/public-api.test.ts b/test/cli/test/public-api.test.ts index 33506f5406c7..e29bffda7222 100644 --- a/test/cli/test/public-api.test.ts +++ b/test/cli/test/public-api.test.ts @@ -1,9 +1,9 @@ import type { TaskMeta } from '@vitest/runner' import type { TestModule, TestUserConfig } from 'vitest/node' -import { runVitest } from '#test-utils' import { resolve } from 'pathe' import { expect, it } from 'vitest' import { rolldownVersion } from 'vitest/node' +import { runVitest } from '../../test-utils' it.each([ { name: 'threads are enabled', pool: 'threads' }, diff --git a/test/cli/test/reported-tasks.test.ts b/test/cli/test/reported-tasks.test.ts index 8e93c9141d30..d5248674c291 100644 --- a/test/cli/test/reported-tasks.test.ts +++ b/test/cli/test/reported-tasks.test.ts @@ -1,8 +1,8 @@ import type { RunnerTestFile } from 'vitest' import type { TestCase, TestCollection, TestModule, TestProject, Vitest } from 'vitest/node' -import { runVitest } from '#test-utils' import { resolve } from 'pathe' import { it as baseTest, expect } from 'vitest' +import { runVitest } from '../../test-utils' const root = resolve(__dirname, '..', 'fixtures', 'reported-tasks') diff --git a/test/cli/test/restricted-fs.test.ts b/test/cli/test/restricted-fs.test.ts index 82599aa84866..49d89f75085c 100644 --- a/test/cli/test/restricted-fs.test.ts +++ b/test/cli/test/restricted-fs.test.ts @@ -1,6 +1,7 @@ -import { runVitest } from '#test-utils' import { expect, test } from 'vitest' +import { runVitest } from '../../test-utils' + test('importing files in restricted fs works correctly', async () => { const { stderr, exitCode } = await runVitest({ root: './fixtures/restricted-fs', diff --git a/test/cli/test/retry-clear-mocks.test.ts b/test/cli/test/retry-clear-mocks.test.ts index 24b7377df597..64460cdcc1a6 100644 --- a/test/cli/test/retry-clear-mocks.test.ts +++ b/test/cli/test/retry-clear-mocks.test.ts @@ -1,6 +1,6 @@ import type { TestCase } from 'vitest/node' -import { runInlineTests } from '#test-utils' import { expect, it } from 'vitest' +import { runInlineTests } from '../../test-utils' it('vitest correctly resets mocks between tests', async () => { const { stderr, results } = await runInlineTests({ diff --git a/test/cli/test/run-custom-env.test.ts b/test/cli/test/run-custom-env.test.ts index 409a643bd1e0..382127c859de 100644 --- a/test/cli/test/run-custom-env.test.ts +++ b/test/cli/test/run-custom-env.test.ts @@ -1,7 +1,8 @@ import { createRequire } from 'node:module' -import { runVitest } from '#test-utils' import { expect, test } from 'vitest' +import { runVitest } from '../../test-utils' + test('correctly runs tests if custom env is a file', async () => { const { stderr, exitCode } = await runVitest({ root: './fixtures/custom-file-env', diff --git a/test/cli/test/scoped-fixtures.test.ts b/test/cli/test/scoped-fixtures.test.ts index 186fc39b4933..65081c75e1af 100644 --- a/test/cli/test/scoped-fixtures.test.ts +++ b/test/cli/test/scoped-fixtures.test.ts @@ -1,11 +1,11 @@ -import type { TestFsStructure } from '#test-utils' import type { afterAll, beforeAll, ExpectStatic, expectTypeOf as ExpectTypeOfFn, SuiteAPI, TestAPI } from 'vitest' import type { ViteUserConfig } from 'vitest/config' import type { TestSpecification, TestUserConfig } from 'vitest/node' -import { runInlineTests, stripIndent } from '#test-utils' +import type { TestFsStructure } from '../../test-utils' import { playwright } from '@vitest/browser-playwright' import { beforeEach, describe, expect, test } from 'vitest' import { rolldownVersion } from 'vitest/node' +import { runInlineTests, stripIndent } from '../../test-utils' // "it" is used inside subtests, we can't "import" it because vitest will inject __vite_ssr_import__ declare const it: TestAPI diff --git a/test/cli/test/server-url.test.ts b/test/cli/test/server-url.test.ts index 929355aeaec3..6e6c092721da 100644 --- a/test/cli/test/server-url.test.ts +++ b/test/cli/test/server-url.test.ts @@ -1,7 +1,8 @@ -import { runInlineTests } from '#test-utils' import basicSsl from '@vitejs/plugin-basic-ssl' import { expect, it } from 'vitest' +import { runInlineTests } from '../../test-utils' + it('api server-url http', async () => { const { stdout, stderr } = await runInlineTests( { 'basic.test.js': `test("basic")` }, diff --git a/test/cli/test/setup-files.test.ts b/test/cli/test/setup-files.test.ts index 6a43eb325d3f..bd320fb7e7da 100644 --- a/test/cli/test/setup-files.test.ts +++ b/test/cli/test/setup-files.test.ts @@ -1,6 +1,6 @@ import { promises as fs } from 'node:fs' -import { editFile, runVitest } from '#test-utils' import { describe, expect, it, test } from 'vitest' +import { editFile, runVitest } from '../../test-utils' test.each(['threads', 'vmThreads'])('%s: print stdout and stderr correctly when called in the setup file', async (pool) => { const { stdout, stderr } = await runVitest({ diff --git a/test/cli/test/shared-env.test.ts b/test/cli/test/shared-env.test.ts index fc5338b225c5..ea466174ff00 100644 --- a/test/cli/test/shared-env.test.ts +++ b/test/cli/test/shared-env.test.ts @@ -1,5 +1,5 @@ -import { runInlineTests, StableTestFileOrderSorter } from '#test-utils' import { expect, test } from 'vitest' +import { runInlineTests, StableTestFileOrderSorter } from '../../test-utils' test.each([ 1, diff --git a/test/cli/test/signal.test.ts b/test/cli/test/signal.test.ts index d5a0f884fdb9..ad368addded9 100644 --- a/test/cli/test/signal.test.ts +++ b/test/cli/test/signal.test.ts @@ -1,7 +1,7 @@ import type { UserConsoleLog } from 'vitest' import type { Reporter, Vitest } from 'vitest/node' -import { runInlineTests } from '#test-utils' import { expect, test } from 'vitest' +import { runInlineTests } from '../../test-utils' test('timeout aborts the signal without fixtures', async () => { const { stderr, results } = await runInlineTests({ diff --git a/test/cli/test/skip-note.test.ts b/test/cli/test/skip-note.test.ts index fbc43d5663c2..9a3b3efb6705 100644 --- a/test/cli/test/skip-note.test.ts +++ b/test/cli/test/skip-note.test.ts @@ -1,7 +1,7 @@ import type { TestCase } from 'vitest/node' import { resolve } from 'node:path' -import { runVitest } from '#test-utils' import { expect, test } from 'vitest' +import { runVitest } from '../../test-utils' const root = resolve(import.meta.dirname, '../fixtures/skip-note') diff --git a/test/cli/test/ssr-runner.test.ts b/test/cli/test/ssr-runner.test.ts index 4c4653e4119f..cfd71b554dde 100644 --- a/test/cli/test/ssr-runner.test.ts +++ b/test/cli/test/ssr-runner.test.ts @@ -1,6 +1,6 @@ -import { runVitest } from '#test-utils' import { version } from 'vite' import { expect, it } from 'vitest' +import { runVitest } from '../../test-utils' // https://github.com/vitest-dev/vitest/issues/9324 it('ssr runner.import() works in configureServer', async () => { diff --git a/test/cli/test/stacktraces.test.ts b/test/cli/test/stacktraces.test.ts index fc4fe52ddb1d..4bdcd83960c2 100644 --- a/test/cli/test/stacktraces.test.ts +++ b/test/cli/test/stacktraces.test.ts @@ -1,8 +1,8 @@ -import { runInlineTests, runVitest } from '#test-utils' import { resolve } from 'pathe' import { glob } from 'tinyglobby' import { describe, expect, it } from 'vitest' import { rolldownVersion } from 'vitest/node' +import { runInlineTests, runVitest } from '../../test-utils' // To prevent the warning coming up in snapshots process.setMaxListeners(20) diff --git a/test/cli/test/standalone.test.ts b/test/cli/test/standalone.test.ts index 7df5610bff45..7f04a9ae7ffa 100644 --- a/test/cli/test/standalone.test.ts +++ b/test/cli/test/standalone.test.ts @@ -1,5 +1,5 @@ -import { runVitest } from '#test-utils' import { test } from 'vitest' +import { runVitest } from '../../test-utils' test('test run is not started when --standalone', async () => { const { vitest } = await runVitest({ diff --git a/test/cli/test/test-specifications.test.ts b/test/cli/test/test-specifications.test.ts index 019f653c5050..f0f745ecccfd 100644 --- a/test/cli/test/test-specifications.test.ts +++ b/test/cli/test/test-specifications.test.ts @@ -1,6 +1,6 @@ import type { TestSpecificationOptions } from 'vitest/node' -import { runInlineTests } from '#test-utils' import { expect, test } from 'vitest' +import { runInlineTests } from '../../test-utils' test.each( [ diff --git a/test/cli/test/tty.test.ts b/test/cli/test/tty.test.ts index 46b27c71322a..4df1a84e4864 100644 --- a/test/cli/test/tty.test.ts +++ b/test/cli/test/tty.test.ts @@ -1,5 +1,5 @@ -import { runVitestCli } from '#test-utils' import { expect, test } from 'vitest' +import { runVitestCli } from '../../test-utils' test('run mode does not get stuck when TTY', async () => { const { vitest } = await runVitestCli('--root', 'fixtures/tty') diff --git a/test/cli/test/unhandled-ignore.test.ts b/test/cli/test/unhandled-ignore.test.ts index 7adbe07e8a2e..b99439f86787 100644 --- a/test/cli/test/unhandled-ignore.test.ts +++ b/test/cli/test/unhandled-ignore.test.ts @@ -1,5 +1,5 @@ -import { runVitest } from '#test-utils' import { expect, test } from 'vitest' +import { runVitest } from '../../test-utils' test('run mode does not get stuck when TTY', async () => { const { vitest } = await runVitest({ diff --git a/test/cli/test/vm-threads.test.ts b/test/cli/test/vm-threads.test.ts index cfe2199530c2..ca69e341a5dc 100644 --- a/test/cli/test/vm-threads.test.ts +++ b/test/cli/test/vm-threads.test.ts @@ -1,6 +1,7 @@ -import { createFile, resolvePath, runInlineTests, runVitest } from '#test-utils' import { expect, test } from 'vitest' +import { createFile, resolvePath, runInlineTests, runVitest } from '../../test-utils' + test('importing files in restricted fs works correctly', async () => { createFile( resolvePath(import.meta.url, '../fixtures/vm-threads/src/external/package-null/package-null.json'), diff --git a/test/cli/test/windows-drive-case.test.ts b/test/cli/test/windows-drive-case.test.ts index acc8010402db..4b44695faa8f 100644 --- a/test/cli/test/windows-drive-case.test.ts +++ b/test/cli/test/windows-drive-case.test.ts @@ -1,6 +1,6 @@ -import { runVitestCli } from '#test-utils' import { join } from 'pathe' import { expect, test } from 'vitest' +import { runVitestCli } from '../../test-utils' const _DRIVE_LETTER_START_RE = /^[A-Z]:\//i const root = join(import.meta.dirname, '../fixtures/windows-drive-case') From 6df093cefbd81d6f5a0d8a83e63cad663662fa9f Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Mon, 23 Mar 2026 11:29:45 +0900 Subject: [PATCH 6/6] test: consolidate --- test/browser/specs/retry-condition.test.ts | 23 ------ test/cli/test/retry-condition.test.ts | 93 ++++++++++++++++++++-- 2 files changed, 88 insertions(+), 28 deletions(-) delete mode 100644 test/browser/specs/retry-condition.test.ts diff --git a/test/browser/specs/retry-condition.test.ts b/test/browser/specs/retry-condition.test.ts deleted file mode 100644 index 5cc7d4f69188..000000000000 --- a/test/browser/specs/retry-condition.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { expect, test } from 'vitest' -import { runInlineBrowserTests } from './utils' - -test('test.retry.condition is corrrectly serialized', async () => { - const { stderr, results } = await runInlineBrowserTests({ - 'basic.test.js': /* js */` - import { expect, test } from 'vitest' - - test('task.retry.condition is corrrectly deserialized', ({ task }) => { - expect(task.retry.condition).toBeInstanceOf(RegExp) - expect(task.retry.condition).toStrictEqual(/retry_this/) - }) - `, - }, { - retry: { - condition: /retry_this/, - }, - }) - expect(stderr).toBe('') - for (const result of results) { - expect(result.state()).toBe('passed') - } -}) diff --git a/test/cli/test/retry-condition.test.ts b/test/cli/test/retry-condition.test.ts index cdd16b707f15..54b1b93865ae 100644 --- a/test/cli/test/retry-condition.test.ts +++ b/test/cli/test/retry-condition.test.ts @@ -1,8 +1,25 @@ +import type { RunVitestConfig } from '#test-utils' import { runInlineTests } from '#test-utils' +import { playwright } from '@vitest/browser-playwright' import { expect, it } from 'vitest' -it('test.retry.condition is corrrectly serialized', async () => { - const { stderr, results } = await runInlineTests({ +function modeToConfig(mode: string): RunVitestConfig { + if (mode === 'playwright') { + return { + browser: { + enabled: true, + headless: true, + screenshotFailures: false, + provider: playwright(), + instances: [{ browser: 'chromium' }], + }, + } + } + return {} +} + +it.for(['node', 'playwright'])('test.retry.condition is corrrectly serialized %s', async (mode) => { + const { stderr, errorTree } = await runInlineTests({ 'basic.test.js': /* js */` import { expect, test } from 'vitest' @@ -10,13 +27,79 @@ it('test.retry.condition is corrrectly serialized', async () => { expect(task.retry.condition).toBeInstanceOf(RegExp) expect(task.retry.condition).toStrictEqual(/retry_this/) }) + + let trial = 0; + test('retry', () => { + trial++ + if (trial === 1) { + throw new Error('retry_this') + } + }) + + let trial2 = 0; + test('not retry', () => { + trial2++ + if (trial2 === 1) { + throw new Error('retry_that') + } + }) `, }, { + ...modeToConfig(mode), retry: { + count: 1, condition: /retry_this/, }, }) - expect(stderr).toBe('') - expect(results).toHaveLength(1) - expect(results[0].state()).toBe('passed') + if (mode === 'playwright') { + expect(stderr).toMatchInlineSnapshot(` + " + ⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯ + + FAIL |chromium| basic.test.js > not retry + Error: retry_that + ❯ basic.test.js:21:17 + 19| trial2++ + 20| if (trial2 === 1) { + 21| throw new Error('retry_that') + | ^ + 22| } + 23| }) + + ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯ + + " + `) + } + else { + expect(stderr).toMatchInlineSnapshot(` + " + ⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯ + + FAIL basic.test.js > not retry + Error: retry_that + ❯ basic.test.js:21:17 + 19| trial2++ + 20| if (trial2 === 1) { + 21| throw new Error('retry_that') + | ^ + 22| } + 23| }) + + ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯ + + " + `) + } + expect(errorTree()).toMatchInlineSnapshot(` + { + "basic.test.js": { + "not retry": [ + "retry_that", + ], + "retry": "passed", + "task.retry.condition is corrrectly deserialized": "passed", + }, + } + `) })