@japa/synthetic-events
Dummy events to build a Japa tests reporter
Synthetic events emits a variety of dummy events you can use to build a test reporter for Japa.
Installation
Install the package from npm registry as follows.
npm i -D @japa/synthetic-events
# yarn
yarn add -D @japa/synthetic-events
Usage
In the following example, the yourReporter
refers to the implementation of the reporter. Feel free to change the implementation.
import { Emitter, Runner } from '@japa/core'
import { fire } from '@japa/synthetic-events'
const emitter = new Emitter()
const runner = new Runner(emitter)
yourReporter()(runner, emitter)
runner['boot']()
fire(emitter)
import type { Emitter, Runner } from '@japa/core'
export function yourReporter() {
return function (runner: Runner, emitter: Emitter) {
emitter.on('suite:start', (suite) => console.log(suite.name))
emitter.on('group:start', (group) => console.log(` ${group.title}`))
emitter.on('test:end', (test) => {
console.log(` > ${test.title} (${test.duration})`)
})
}
}