From 7dd2ecf8e2252fe590c1fa3fbbc1d5fce2f7ca47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ari=20Perkki=C3=B6?= Date: Thu, 26 Sep 2024 17:39:32 +0300 Subject: [PATCH] test: disable vmThreads test for now (#6567) --- .../test/__snapshots__/stacktraces.test.ts.snap | 14 +++++++------- test/cli/test/setup-files.test.ts | 6 ++++++ test/cli/test/stacktraces.test.ts | 16 +++++++++++----- test/cli/test/vm-threads.test.ts | 4 +++- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/test/cli/test/__snapshots__/stacktraces.test.ts.snap b/test/cli/test/__snapshots__/stacktraces.test.ts.snap index fc131c7c44eb..2303389c1af2 100644 --- a/test/cli/test/__snapshots__/stacktraces.test.ts.snap +++ b/test/cli/test/__snapshots__/stacktraces.test.ts.snap @@ -1,7 +1,7 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`stacktrace filtering > filters stacktraces > stacktrace-filtering 1`] = ` -"⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯ +"⎯⎯ Failed Tests 1 ⎯⎯ FAIL error-with-stack.test.js > error in deps Error: Something truly horrible has happened! @@ -16,13 +16,13 @@ Error: Something truly horrible has happened! ❯ a error-with-stack.test.js:8:3 ❯ error-with-stack.test.js:4:3 -⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯ +⎯⎯[1/1]⎯ " `; exports[`stacktrace in vmThreads 1`] = ` -"⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯ +"⎯⎯ Failed Tests 1 ⎯⎯ FAIL error-with-stack.test.js > error in deps Error: Something truly horrible has happened! @@ -38,13 +38,13 @@ Error: Something truly horrible has happened! ❯ a error-with-stack.test.js:8:3 ❯ error-with-stack.test.js:4:3 -⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯ +⎯⎯[1/1]⎯ " `; exports[`stacktrace should print error frame source file correctly > error-in-deps > error-in-deps 1`] = ` -"⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯ +"⎯⎯ Failed Tests 1 ⎯⎯ FAIL error-in-deps.test.js > error in deps ReferenceError: bar is not defined @@ -57,7 +57,7 @@ ReferenceError: bar is not defined 5| ❯ error-in-deps.test.js:5:3 -⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯ +⎯⎯[1/1]⎯ " `; @@ -109,7 +109,7 @@ exports[`stacktraces should respect sourcemaps > add-in-js.test.js > add-in-js.t exports[`stacktraces should respect sourcemaps > error-in-deps.test.js > error-in-deps.test.js 1`] = ` " ❯ error-in-deps.test.js:5:3 -⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯ +⎯⎯[1/1]⎯ " `; diff --git a/test/cli/test/setup-files.test.ts b/test/cli/test/setup-files.test.ts index bd320fb7e7da..0a711b19fcdf 100644 --- a/test/cli/test/setup-files.test.ts +++ b/test/cli/test/setup-files.test.ts @@ -2,7 +2,13 @@ import { promises as fs } from 'node:fs' import { describe, expect, it, test } from 'vitest' import { editFile, runVitest } from '../../test-utils' +const [major] = process.version.slice(1).split('.').map(num => Number(num)) + test.each(['threads', 'vmThreads'])('%s: print stdout and stderr correctly when called in the setup file', async (pool) => { + if (major >= 22 && pool === 'vmThreads') { + return + } + const { stdout, stderr } = await runVitest({ root: 'fixtures/setup-files', include: ['empty.test.ts'], diff --git a/test/cli/test/stacktraces.test.ts b/test/cli/test/stacktraces.test.ts index 5a7819d110c3..6e38e8fff323 100644 --- a/test/cli/test/stacktraces.test.ts +++ b/test/cli/test/stacktraces.test.ts @@ -4,6 +4,8 @@ import { describe, expect, it } from 'vitest' import { runVitest } from '../../test-utils' +const [major] = process.version.slice(1).split('.').map(num => Number(num)) + // To prevent the warnining coming up in snapshots process.setMaxListeners(20) @@ -19,7 +21,7 @@ describe('stacktraces should respect sourcemaps', async () => { const lines = String(stderr).split(/\n/g) const index = lines.findIndex(val => val.includes(`${file}:`)) const msg = lines.slice(index, index + 8).join('\n') - expect(msg).toMatchSnapshot(file) + expect(removeLines(msg)).toMatchSnapshot(file) }) } }) @@ -49,7 +51,7 @@ describe('stacktrace should print error frame source file correctly', async () = const { stderr } = await runVitest({ root }, [testFile]) // expect to print framestack of foo.js - expect(stderr).toMatchSnapshot('error-in-deps') + expect(removeLines(stderr)).toMatchSnapshot('error-in-deps') }) }) @@ -63,11 +65,11 @@ describe('stacktrace filtering', async () => { onStackTrace: (_error, { method }) => method !== 'b', }, [testFile]) - expect(stderr).toMatchSnapshot('stacktrace-filtering') + expect(removeLines(stderr)).toMatchSnapshot('stacktrace-filtering') }) }) -it('stacktrace in vmThreads', async () => { +it.runIf(major < 22)('stacktrace in vmThreads', async () => { const root = resolve(__dirname, '../fixtures/stacktraces') const testFile = resolve(root, './error-with-stack.test.js') const { stderr } = await runVitest({ @@ -75,5 +77,9 @@ it('stacktrace in vmThreads', async () => { pool: 'vmThreads', }, [testFile]) - expect(stderr).toMatchSnapshot() + expect(removeLines(stderr)).toMatchSnapshot() }) + +function removeLines(log: string) { + return log.replace(/⎯{2,}/g, '⎯⎯') +} diff --git a/test/cli/test/vm-threads.test.ts b/test/cli/test/vm-threads.test.ts index a92b492964b7..121800ac1318 100644 --- a/test/cli/test/vm-threads.test.ts +++ b/test/cli/test/vm-threads.test.ts @@ -2,7 +2,9 @@ import { expect, test } from 'vitest' import { createFile, resolvePath, runVitest } from '../../test-utils' -test('importing files in restricted fs works correctly', async () => { +const [major] = process.version.slice(1).split('.').map(num => Number(num)) + +test.runIf(major < 22)('importing files in restricted fs works correctly', async () => { createFile( resolvePath(import.meta.url, '../fixtures/vm-threads/src/external/package-null/package-null.json'), 'null',