From 05a5ff54d0a620f9866bda99dfa6efbf564cfa5c Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Tue, 22 Apr 2025 17:17:47 +0800 Subject: [PATCH] Add failed test back (#17384) --- jest.config.js | 2 -- .../cli/patterns-backslashes/.gitignore | 2 +- .../cli/patterns-symlinks/.gitignore | 2 +- tests/integration/run-cli.js | 26 ++++++++++++++++--- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/jest.config.js b/jest.config.js index c24814188..873afa7be 100644 --- a/jest.config.js +++ b/jest.config.js @@ -55,8 +55,6 @@ if (SKIP_TESTS_WITH_NEW_SYNTAX) { "/tests/integration/__tests__/config-invalid.js", // Fails on Node.js v14 "/tests/dts/unit/run.js", - // Unknown reason, fails on Node.js v14 - "/tests/integration/__tests__/config-file-typescript.js", ); } diff --git a/tests/integration/cli/patterns-backslashes/.gitignore b/tests/integration/cli/patterns-backslashes/.gitignore index 96fef51b5..e53c48ff5 100644 --- a/tests/integration/cli/patterns-backslashes/.gitignore +++ b/tests/integration/cli/patterns-backslashes/.gitignore @@ -1,2 +1,2 @@ # dynamically created by tests -* +test-* diff --git a/tests/integration/cli/patterns-symlinks/.gitignore b/tests/integration/cli/patterns-symlinks/.gitignore index 96fef51b5..e53c48ff5 100644 --- a/tests/integration/cli/patterns-symlinks/.gitignore +++ b/tests/integration/cli/patterns-symlinks/.gitignore @@ -1,2 +1,2 @@ # dynamically created by tests -* +test-* diff --git a/tests/integration/run-cli.js b/tests/integration/run-cli.js index 458494829..819a3fa85 100644 --- a/tests/integration/run-cli.js +++ b/tests/integration/run-cli.js @@ -10,6 +10,7 @@ const CLI_WORKER_FILE = url.fileURLToPath( const INTEGRATION_TEST_DIRECTORY = url.fileURLToPath( new URL("./", import.meta.url), ); +const IS_CI = Boolean(process.env.CI); const removeFinalNewLine = (string) => string.endsWith("\n") ? string.slice(0, -1) : string; const SUPPORTS_DISABLE_WARNING_FLAG = @@ -39,7 +40,6 @@ function runCliWorker(dir, args, options) { NO_COLOR: "1", }, }); - worker.unref(); worker.on("message", ({ action, data }) => { if (action === "write-file") { @@ -70,7 +70,27 @@ function runCliWorker(dir, args, options) { reject(error); }); - worker.send(options); + worker.send(options, (error) => { + if (!error) { + return; + } + + // It can fail with `write EPIPE` error when running node with unsupported flags like `--experimental-strip-types` + // Let's ignore and wait for the `close` event + if ( + error.code === "EPIPE" && + error.syscall === "write" && + nodeOptions.length > 0 + ) { + if (IS_CI) { + // eslint-disable-next-line no-console + console.error(Object.assign(error, { dir, args, options, worker })); + } + return; + } + + reject(error); + }); }); } @@ -130,7 +150,7 @@ function runCli(dir, args = [], options = {}) { expect(value).toEqual(testOptions[name]); } } else { - snapshot = snapshot || {}; + snapshot = snapshot ?? {}; snapshot[name] = value; } }