Skip to content

Commit 9695cf8

Browse files
test: make sure the right error is emitted
1 parent 95d2869 commit 9695cf8

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/transform.test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,3 +318,25 @@ test("should not polyfill using Symbol.asyncDispose", (t) => {
318318
});
319319
t.assert.snapshot(code);
320320
});
321+
322+
test("should have proper error code", (t) => {
323+
const inputCode = "module F { export type x = number }";
324+
try {
325+
transformSync(inputCode, {
326+
mode: "transform",
327+
});
328+
} catch (error) {
329+
assert.strictEqual(error.code, "UnsupportedSyntax");
330+
}
331+
});
332+
333+
test("should have proper error code", (t) => {
334+
const inputCode = "const foo;";
335+
try {
336+
transformSync(inputCode, {
337+
mode: "transform",
338+
});
339+
} catch (error) {
340+
assert.strictEqual(error.code, "InvalidSyntax");
341+
}
342+
});

0 commit comments

Comments
 (0)