mcollina / borp

node:test runner wrapper with TypeScript support
MIT License
158 stars 15 forks source link

Unclear how to use a custom reporter #68

Closed jsumners-nr closed 3 months ago

jsumners-nr commented 3 months ago

https://github.com/mcollina/borp/blob/b34899948a03eed6a44bcca314547ee69f4d6cff/borp.js#L115-L124

If I have a reporter, e.g. ./test/lib/my-reporter.js, with code like:

my-reporter.js ```js 'use strict' const OUTPUT_MODE = process.env.OUTPUT_MODE?.toLowerCase() ?? 'simple' const isSilent = OUTPUT_MODE === 'quiet' || OUTPUT_MODE === 'silent' const { Transform } = require('node:stream') const testReporter = new Transform({ writableObjectMode: true, transform(event, encoding, callback) { switch (event.type) { case 'test:pass': { if (isSilent === true) { return callback(null, null) } return callback(null, `passed: ${event.data.file}\n`) } case 'test:fail': { return callback(null, `failed: ${event.data.file}\n`) } default: { callback(null, null) } } } }) module.exports = testReporter ```

Then I am unclear how to get borp to use it. I think we should be doing borp --reporter ':./test/lib/my-reporter.js' 'test/**/*.test.js', but I'm having no luck with it.