diff --git a/borp.js b/borp.js index ac3ebc9..a01fc66 100755 --- a/borp.js +++ b/borp.js @@ -102,7 +102,7 @@ try { for (const input of args.values.reporter) { const [name, dest] = input.split(':') const Ctor = reporters[name] || await import(name).then((m) => m.default || m) - const reporter = Object.getOwnPropertyDescriptor(Ctor.prototype, 'constructor') ? new Ctor() : Ctor + const reporter = Ctor.prototype && Object.getOwnPropertyDescriptor(Ctor.prototype, 'constructor') ? new Ctor() : Ctor let output = process.stdout if (dest) { output = createWriteStream(dest) @@ -140,6 +140,7 @@ try { /* c8 ignore next 3 */ } catch (err) { console.error(err) + process.exitCode = 1 } finally { if (covDir) { try { diff --git a/test/cli.test.js b/test/cli.test.js index 362c1f9..828277b 100644 --- a/test/cli.test.js +++ b/test/cli.test.js @@ -62,16 +62,29 @@ test('disable ts and run no tests', async () => { }) test('reporter from node_modules', async () => { - const cwd = join(import.meta.url, '..', 'fixtures', 'ts-esm2') - await rm(path.join(cwd, 'dist'), { recursive: true, force: true }) + const cwd = join(import.meta.url, '..', 'fixtures', 'ts-esm') const { stdout } = await execa('node', [ borp, '--reporter=spec', - '--reporter=@reporters/silent', - '--no-typescript' + '--reporter=@reporters/silent' ], { cwd }) - strictEqual(stdout.indexOf('tests 0') >= 0, true) + strictEqual(stdout.indexOf('tests 2') >= 0, true) +}) + +test('gh reporter', async () => { + const cwd = join(import.meta.url, '..', 'fixtures', 'js-esm') + const { stdout } = await execa('node', [ + borp, + '--reporter=gh' + ], { + cwd, + env: { + GITHUB_ACTIONS: '1' + } + }) + + strictEqual(stdout.indexOf('::notice') >= 0, true) })