Skip to content

Commit 50b7054

Browse files
committed
test: inline stderr since it contains paths
1 parent 491e549 commit 50b7054

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

test/__tests__/__snapshots__/infer-parser.js.snap

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`--check with unknown path and no parser multiple files (stderr) 1`] = `
4-
"[error] FOO: UndefinedParserError: No parser could be inferred for file "/Users/jg/code/prettier-cli/test/__fixtures__/infer-parser/FOO".
5-
[warn] foo.js
6-
[warn] Code style issues found in 1 file. Run Prettier with --write to fix."
7-
`;
8-
93
exports[`--check with unknown path and no parser multiple files (stdout) 1`] = `"Checking formatting..."`;
104

115
exports[`--check with unknown path and no parser specific file is ignored (stderr) 1`] = `""`;
@@ -19,8 +13,6 @@ exports[`--list-different with unknown path and no parser multiple files (stderr
1913

2014
exports[`--list-different with unknown path and no parser specific file should be ignored (stderr) 1`] = `""`;
2115

22-
exports[`--write with unknown path and no parser multiple files (stderr) 1`] = `"[error] FOO: UndefinedParserError: No parser could be inferred for file "/Users/jg/code/prettier-cli/test/__fixtures__/infer-parser/FOO"."`;
23-
2416
exports[`--write with unknown path and no parser multiple files (stdout) 1`] = `"foo.js"`;
2517

2618
exports[`--write with unknown path and no parser multiple files (write) 1`] = `

test/__tests__/infer-parser.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
import { runCli } from "../utils";
2+
import { color } from "specialist";
3+
import path from 'node:path';
4+
5+
const FIXTURES_PATH = path.join(process.cwd(), "test", "__fixtures__");
26

37
describe("stdin no path and no parser", () => {
48
describe("logs error and exits with 2", () => {
@@ -104,6 +108,9 @@ describe("--check with unknown path and no parser", () => {
104108
runCli("infer-parser/", ["--check", "*"]).test({
105109
status: 1,
106110
write: [],
111+
stderr: `[${color.red('error')}] FOO: UndefinedParserError: No parser could be inferred for file "${FIXTURES_PATH}/infer-parser/FOO".
112+
[${color.yellow('warn')}] foo.js
113+
[${color.yellow('warn')}] Code style issues found in 1 file. Run Prettier with --write to fix.`
107114
});
108115
});
109116
});
@@ -138,6 +145,7 @@ describe("--write with unknown path and no parser", () => {
138145
describe("multiple files", () => {
139146
runCli("infer-parser/", ["--write", "*"]).test({
140147
status: 1,
148+
stderr: `[${color.red('error')}] FOO: UndefinedParserError: No parser could be inferred for file "${FIXTURES_PATH}/infer-parser/FOO".`,
141149
});
142150
});
143151
});

0 commit comments

Comments
 (0)