-
-
Notifications
You must be signed in to change notification settings - Fork 184
Expand file tree
/
Copy patherrors.spec.ts
More file actions
27 lines (21 loc) · 925 Bytes
/
errors.spec.ts
File metadata and controls
27 lines (21 loc) · 925 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
import * as fs from "fs";
import * as path from "path";
import { runCli } from "./run";
const srcFilePath = path.resolve(__dirname, "errors", "error.ts");
const outFilePath = path.resolve(__dirname, "errors", "error.lua");
const errorMessage = "Unable to convert function with no 'this' parameter to function with 'this'.";
afterEach(() => {
if (fs.existsSync(outFilePath)) fs.unlinkSync(outFilePath);
});
test("should report errors", async () => {
const { exitCode, output } = await runCli([srcFilePath]);
expect(output).toContain(errorMessage);
expect(exitCode).toBe(2);
expect(fs.existsSync(outFilePath)).toBe(true);
});
test("shouldn't emit files with --noEmitOnError", async () => {
const { exitCode, output } = await runCli(["--noEmitOnError", srcFilePath]);
expect(output).toContain(errorMessage);
expect(exitCode).toBe(1);
expect(fs.existsSync(outFilePath)).toBe(false);
});