-
-
Notifications
You must be signed in to change notification settings - Fork 138
Expand file tree
/
Copy pathjsfmt.spec.mjs
More file actions
28 lines (24 loc) · 855 Bytes
/
jsfmt.spec.mjs
File metadata and controls
28 lines (24 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { prettier, plugin } from "../../tests_config/get_engine.mjs";
import stripAnsi from "strip-ansi";
async function raiseSyntaxError() {
await prettier.format(`<?php _`, {
plugins: [plugin],
parser: "php",
});
}
test("Prettier throws SyntaxErrors", async () => {
await expect(raiseSyntaxError).rejects.toThrow(SyntaxError);
});
test("Syntax errors have the expected structure", async () => {
try {
await raiseSyntaxError();
} catch (err) {
// Convert error to plain object since additional properties are not snapshotted otherwise
const errObject = Object.assign({}, err, {
// Strip ANSI from code frame since not all test environments may support it
codeFrame: stripAnsi(err.codeFrame),
});
// eslint-disable-next-line jest/no-conditional-expect
expect(errObject).toMatchSnapshot();
}
});