@japa/synthetic-events
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

@japa/synthetic-events

Dummy events to build a Japa tests reporter

github-actions-image npm-image license-image typescript-image

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})`)
    })
  }
}

Package Sidebar

Install

npm i @japa/synthetic-events

Weekly Downloads

2

Version

2.0.2

License

MIT

Unpacked Size

21.8 kB

Total Files

11

Last publish

Collaborators

  • virk
  • romainlanz
  • julien-r44