Skip to content

Commit

Permalink
fix test on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
fasttime committed Dec 29, 2023
1 parent b90c67a commit 01f5718
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions tests/tools/check-rule-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,29 @@ describe("check-rule-examples", () => {

await assert.rejects(
promise,
{
code: 1,
stdout: "",
stderr:
({ code, stdout, stderr }) => {
assert.strictEqual(code, 1);
assert.strictEqual(stdout, "");

// Remove OS-dependent path except base name.
const normalizedStderr =
// eslint-disable-next-line no-control-regex -- escaping control character
stderr.replace(/(?<=\x1B\[4m).*(?=bad-examples\.md)/u, "");

const expectedStderr =
"\x1B[0m\x1B[0m\n" +
"\x1B[0m\x1B[4mtests/fixtures/bad-examples.md\x1B[24m\x1B[0m\n" +
"\x1B[0m\x1B[4mbad-examples.md\x1B[24m\x1B[0m\n" +
"\x1B[0m \x1B[2m11:4\x1B[22m \x1B[31merror\x1B[39m Missing language tag: use one of 'javascript', 'js' or 'jsx'\x1B[0m\n" +
"\x1B[0m \x1B[2m12:1\x1B[22m \x1B[31merror\x1B[39m Syntax error: 'import' and 'export' may appear only with 'sourceType: module'\x1B[0m\n" +
"\x1B[0m \x1B[2m20:5\x1B[22m \x1B[31merror\x1B[39m Nonstandard language tag 'ts': use one of 'javascript', 'js' or 'jsx'\x1B[0m\n" +
"\x1B[0m \x1B[2m23:7\x1B[22m \x1B[31merror\x1B[39m Syntax error: Identifier 'foo' has already been declared\x1B[0m\n" +
"\x1B[0m \x1B[2m31:1\x1B[22m \x1B[31merror\x1B[39m Example code should contain a configuration comment like /* eslint no-restricted-syntax: \"error\" */\x1B[0m\n" +
"\x1B[0m\x1B[0m\n" +
"\x1B[0m\x1B[31m\x1B[1m✖ 5 problems (5 errors, 0 warnings)\x1B[22m\x1B[39m\x1B[0m\n" +
"\x1B[0m\x1B[31m\x1B[1m\x1B[22m\x1B[39m\x1B[0m\n"
"\x1B[0m\x1B[31m\x1B[1m\x1B[22m\x1B[39m\x1B[0m\n";

assert.strictEqual(normalizedStderr, expectedStderr);
return true;
}
);
});
Expand Down

0 comments on commit 01f5718

Please sign in to comment.