From ab8c9114021ec1b076e4dee90b8943880980b9ad Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Fri, 28 Aug 2026 14:53:03 +0800 Subject: [PATCH] Fix test on Node.js v26 (#19927) --- .../__snapshots__/config-invalid.js.snap | 9 --------- .../__snapshots__/invalid-ignore.js.snap | 9 --------- tests/integration/__tests__/config-invalid.js | 16 ++++++++++++++++ tests/integration/__tests__/invalid-ignore.js | 18 +++++++++++++++++- 4 files changed, 33 insertions(+), 19 deletions(-) delete mode 100644 tests/integration/__tests__/__snapshots__/invalid-ignore.js.snap diff --git a/tests/integration/__tests__/__snapshots__/config-invalid.js.snap b/tests/integration/__tests__/__snapshots__/config-invalid.js.snap index 5a47307fb..7288ad961 100644 --- a/tests/integration/__tests__/__snapshots__/config-invalid.js.snap +++ b/tests/integration/__tests__/__snapshots__/config-invalid.js.snap @@ -86,12 +86,3 @@ exports[`throw error with invalid config precedence option (configPrecedence) 1 "write": [], } `; - -exports[`throw error with invalid config target (directory) 1`] = ` -{ - "stderr": "[error] Invalid configuration: -[error] Unable to read '/config/invalid/folder/.prettierrc': EISDIR: illegal operation on a directory, read", - "stdout": "", - "write": [], -} -`; diff --git a/tests/integration/__tests__/__snapshots__/invalid-ignore.js.snap b/tests/integration/__tests__/__snapshots__/invalid-ignore.js.snap deleted file mode 100644 index 8b6e2145b..000000000 --- a/tests/integration/__tests__/__snapshots__/invalid-ignore.js.snap +++ /dev/null @@ -1,9 +0,0 @@ -// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing - -exports[`throw error with invalid ignore 1`] = ` -{ - "stderr": "[error] Unable to read '.prettierignore': EISDIR: illegal operation on a directory, read", - "stdout": "", - "write": [], -} -`; diff --git a/tests/integration/__tests__/config-invalid.js b/tests/integration/__tests__/config-invalid.js index 440ef6633..ef79dd845 100644 --- a/tests/integration/__tests__/config-invalid.js +++ b/tests/integration/__tests__/config-invalid.js @@ -35,6 +35,22 @@ describe("throw error with invalid config target (directory)", () => { "folder/.prettierrc", // this is a directory ]).test({ status: "non-zero", + stderr: + /* + On Node.js<26 + + ``` + EISDIR: illegal operation on a directory, read + ``` + + On Node.js>=26 + ``` + EISDIR: illegal operation on a directory, read '/config/invalid/folder/.prettierrc' + ``` + */ + expect.stringContaining("EISDIR: illegal operation on a directory, read"), + stdout: "", + write: [], }); }); diff --git a/tests/integration/__tests__/invalid-ignore.js b/tests/integration/__tests__/invalid-ignore.js index c7caa4a03..884e8d587 100644 --- a/tests/integration/__tests__/invalid-ignore.js +++ b/tests/integration/__tests__/invalid-ignore.js @@ -7,6 +7,22 @@ const { __dirname } = createEsmUtils(import.meta); describe("throw error with invalid ignore", () => { runCli("cli/invalid-ignore", ["something.js"]).test({ status: "non-zero", + stderr: + /* + On Node.js<26 + + ``` + EISDIR: illegal operation on a directory, read + ``` + + On Node.js>=26 + ``` + EISDIR: illegal operation on a directory, read '...' + ``` + */ + expect.stringContaining("EISDIR: illegal operation on a directory, read"), + stdout: "", + write: [], }); test("sync api", async () => { @@ -17,6 +33,6 @@ describe("throw error with invalid ignore", () => { "../cli/invalid-ignore/.prettierignore", ), }), - ).rejects.toThrow(/EISDIR: illegal operation on a directory/); + ).rejects.toThrow(/EISDIR: illegal operation on a directory, read/); }); });