Fix test on Node.js v26 (#19927)

This commit is contained in:
fisker Cheung authored and fisker committed 2026-09-16 16:05:21 +08:00
1 parent 4a5adf9c03
commit ab8c911402
4 files changed
+33 -19

No files matched your search

@@ -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 '<cli>/config/invalid/folder/.prettierrc': EISDIR: illegal operation on a directory, read",
"stdout": "",
"write": [],
}
`;
@@ -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": [],
}
`;
@@ -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 '<cli>/config/invalid/folder/.prettierrc'
```
*/
expect.stringContaining("EISDIR: illegal operation on a directory, read"),
stdout: "",
write: [],
});
});
+17 -1
View File
@@ -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/);
});
});