diff --git a/.taprc b/.taprc index eb6eb3e..244e316 100644 --- a/.taprc +++ b/.taprc @@ -1,2 +1,8 @@ files: - test/**/*.test.js + +coverage: + lines: 91 + functions: 100 + branches: 83 + statements: 91 diff --git a/test/cli.test.js b/test/cli.test.js index 0c06595..c6ff152 100644 --- a/test/cli.test.js +++ b/test/cli.test.js @@ -14,7 +14,8 @@ const errorLine = const fatalErrorLine = '{"level":60,"time":1597426544906,"pid":43024,"hostname":"Gregors-MacBook-Pro.local","name":"probot","stack":"Error: Oh no!\\n at Object. (/Users/gregor/Projects/probot/pino/example.js:59:12)\\n at Module._compile (internal/modules/cjs/loader.js:1137:30)\\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)\\n at Module.load (internal/modules/cjs/loader.js:985:32)\\n at Function.Module._load (internal/modules/cjs/loader.js:878:14)\\n at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)\\n at internal/main/run_main_module.js:17:47","type":"Error","msg":"Oh no!"}\n'; -const stripAnsiColorRE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g +const stripAnsiColorRE = + /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g; const env = { // disable colors @@ -29,7 +30,10 @@ test("cli", (t) => { const child = spawn(nodeBinaryPath, [cliPath], { env }); child.on("error", t.threw); child.stdout.on("data", (data) => { - t.equal(data.toString().replace(stripAnsiColorRE, ''), `INFO (probot): hello future\n`); + t.equal( + data.toString().replace(stripAnsiColorRE, ""), + `INFO (probot): hello future\n` + ); }); child.stdin.write(logLine); t.teardown(() => child.kill()); @@ -41,9 +45,15 @@ test("cli", (t) => { const child = spawn(nodeBinaryPath, [cliPath], { env }); child.on("error", t.threw); child.stdout.on("data", (data) => { - t.match(data.toString().replace(stripAnsiColorRE, ''), /event: "installation_repositories.added"/); - t.match(data.toString().replace(stripAnsiColorRE, ''), /status: 500/); - t.match(data.toString().replace(stripAnsiColorRE, ''), /x-github-request-id: "789"/); + t.match( + data.toString().replace(stripAnsiColorRE, ""), + /event: "installation_repositories.added"/ + ); + t.match(data.toString().replace(stripAnsiColorRE, ""), /status: 500/); + t.match( + data.toString().replace(stripAnsiColorRE, ""), + /x-github-request-id: "789"/ + ); t.match( data.toString(), /url: "https:\/\/api.github.com\/repos\/octocat\/hello-world\/"/ @@ -60,7 +70,7 @@ test("cli", (t) => { }); child.on("error", t.threw); child.stdout.on("data", (data) => { - t.equal(data.toString().replace(stripAnsiColorRE, ''), logLine); + t.equal(data.toString().replace(stripAnsiColorRE, ""), logLine); }); child.stdin.write(logLine); t.teardown(() => child.kill()); @@ -73,7 +83,10 @@ test("cli", (t) => { }); child.on("error", t.threw); child.stdout.on("data", (data) => { - t.equal(data.toString().replace(stripAnsiColorRE, ''), logLine.replace('"level":30', '"level":"info"')); + t.equal( + data.toString().replace(stripAnsiColorRE, ""), + logLine.replace('"level":30', '"level":"info"') + ); }); child.stdin.write(logLine); t.teardown(() => child.kill()); @@ -130,7 +143,10 @@ test("cli", (t) => { }); child.on("error", t.threw); child.stdout.on("data", (data) => { - const errorStringLines = data.toString().replace(stripAnsiColorRE, '').split(/\n/); + const errorStringLines = data + .toString() + .replace(stripAnsiColorRE, "") + .split(/\n/); t.equal(errorStringLines[0].trim(), "ERROR (probot): Oops"); // skip the error stack, normalize Sentry Event ID, compare error details only @@ -192,7 +208,10 @@ sentryEventId: 123` }); child.on("error", t.threw); child.stdout.on("data", (data) => { - t.match(data.toString().replace(stripAnsiColorRE, ''), /^FATAL \(probot\): Oh no!\n/); + t.match( + data.toString().replace(stripAnsiColorRE, ""), + /^FATAL \(probot\): Oh no!\n/ + ); }); child.stdin.write(fatalErrorLine);