[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

test: add test to detect event listeners leak warnings (#8827)

authored by

Ari Perkkiö and committed by
GitHub
(Oct 27, 2025, 10:17 AM +0100) 7c8255f3 06208d30

+91
+55
test/cli/test/no-unexpected-logging.test.ts
··· 1 + import { test } from 'vitest' 2 + import { runVitest, StableTestFileOrderSorter } from '../../test-utils' 3 + 4 + // Test to detect that there are no unexpected logs, like NodeJS MaxListenersExceededWarning 5 + 6 + describe.each(['forks', 'threads', 'vmForks', 'vmThreads'] as const)('%s', (pool) => { 7 + test.each([true, false])(`should not log anything unexpected { isolate: %s }`, async (isolate) => { 8 + const { stdout, stderr } = await runVitest({ 9 + root: './fixtures/no-unexpected-logging', 10 + pool, 11 + isolate, 12 + sequence: { sequencer: StableTestFileOrderSorter }, 13 + }) 14 + 15 + expect(stderr).toBe('') 16 + 17 + expect(normalizeOutput(stdout)).toBe(` 18 + RUN v[...] 19 + 20 + ✓ fixture-1.test.ts > test 1 [...]ms 21 + ✓ fixture-10.test.ts > test 10 [...]ms 22 + ✓ fixture-11.test.ts > test 11 [...]ms 23 + ✓ fixture-12.test.ts > test 12 [...]ms 24 + ✓ fixture-2.test.ts > test 2 [...]ms 25 + ✓ fixture-3.test.ts > test 3 [...]ms 26 + ✓ fixture-4.test.ts > test 4 [...]ms 27 + ✓ fixture-5.test.ts > test 5 [...]ms 28 + ✓ fixture-6.test.ts > test 6 [...]ms 29 + ✓ fixture-7.test.ts > test 7 [...]ms 30 + ✓ fixture-8.test.ts > test 8 [...]ms 31 + ✓ fixture-9.test.ts > test 9 [...]ms 32 + 33 + Test Files 12 passed (12) 34 + Tests 12 passed (12) 35 + Start at [...] 36 + Duration [...]ms (transform [...]ms, setup [...]ms, collect [...]ms, tests [...]ms, environment [...]ms, prepare [...]ms) 37 + 38 + `.trim()) 39 + }) 40 + }) 41 + 42 + function normalizeOutput(stdtout: string) { 43 + const rows = stdtout.replace(/\d?\.?\d+m?s/g, '[...]ms').split('\n').map((row) => { 44 + if (row.includes('RUN v')) { 45 + return `${row.split('RUN v')[0]}RUN v[...]` 46 + } 47 + 48 + if (row.includes('Start at')) { 49 + return row.replace(/\d+:\d+:\d+/, '[...]') 50 + } 51 + return row 52 + }) 53 + 54 + return rows.join('\n').trim() 55 + }
+3
test/cli/fixtures/no-unexpected-logging/fixture-1.test.ts
··· 1 + import { test } from "vitest"; 2 + 3 + test("test 1", () => { })
+3
test/cli/fixtures/no-unexpected-logging/fixture-10.test.ts
··· 1 + import { test } from "vitest"; 2 + 3 + test("test 10", () => { })
+3
test/cli/fixtures/no-unexpected-logging/fixture-11.test.ts
··· 1 + import { test } from "vitest"; 2 + 3 + test("test 11", () => { })
+3
test/cli/fixtures/no-unexpected-logging/fixture-12.test.ts
··· 1 + import { test } from "vitest"; 2 + 3 + test("test 12", () => { })
+3
test/cli/fixtures/no-unexpected-logging/fixture-2.test.ts
··· 1 + import { test } from "vitest"; 2 + 3 + test("test 2", () => { })
+3
test/cli/fixtures/no-unexpected-logging/fixture-3.test.ts
··· 1 + import { test } from "vitest"; 2 + 3 + test("test 3", () => { })
+3
test/cli/fixtures/no-unexpected-logging/fixture-4.test.ts
··· 1 + import { test } from "vitest"; 2 + 3 + test("test 4", () => { })
+3
test/cli/fixtures/no-unexpected-logging/fixture-5.test.ts
··· 1 + import { test } from "vitest"; 2 + 3 + test("test 5", () => { })
+3
test/cli/fixtures/no-unexpected-logging/fixture-6.test.ts
··· 1 + import { test } from "vitest"; 2 + 3 + test("test 6", () => { })
+3
test/cli/fixtures/no-unexpected-logging/fixture-7.test.ts
··· 1 + import { test } from "vitest"; 2 + 3 + test("test 7", () => { })
+3
test/cli/fixtures/no-unexpected-logging/fixture-8.test.ts
··· 1 + import { test } from "vitest"; 2 + 3 + test("test 8", () => { })
+3
test/cli/fixtures/no-unexpected-logging/fixture-9.test.ts
··· 1 + import { test } from "vitest"; 2 + 3 + test("test 9", () => { })