-
-
Notifications
You must be signed in to change notification settings - Fork 18
Closed
Description
Lines 115 to 124 in b348999
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 = Ctor.prototype && Object.getOwnPropertyDescriptor(Ctor.prototype, 'constructor') ? new Ctor() : Ctor | |
let output = process.stdout | |
if (dest) { | |
output = createWriteStream(dest) | |
} | |
pipes.push([reporter, output]) | |
} |
If I have a reporter, e.g. ./test/lib/my-reporter.js
, with code like:
my-reporter.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.
Metadata
Metadata
Assignees
Labels
No labels