Skip to content

Quickstart

Getting started with @nhtio/japa-junit-reporter is quick and easy. Just follow the steps below and you'll be up and running in no time.

Installation

You can install @nhtio/japa-junit-reporter directly from your preferred package manager

sh
npm i @nhtio/japa-junit-reporter
sh
pnpm add @nhtio/japa-junit-reporter
sh
yarn add @nhtio/japa-junit-reporter

Usage

  1. Import the JunitReporter class from the package:

    typescript
    import { JunitReporter } from '@nhtio/japa-junit-reporter'
  2. Add the JunitReporter to your Japa config in 3 ways:

    a. If you have only one reporter, simply use reporterConfig()

    typescript
    configure({
        // ...other Japa configuration
        reporters: JunitReporter.reporterConfig({ reportPath: "foo/bar.xml" })
    })

    b. If you have other reporters, use listConfig()

    typescript
    configure({
        // ...other Japa configuration
        reporters: {
            activated: [JunitReporter.name],
            list: [JunitReporter.listConfig({ reportPath: "foo/bar.xml" })],
        },
    })

    c. If you need access to additional config, feel free to use the native way:

    typescript
    configure({
        // ...other Japa configuration
        reporters: {
            activated: [JunitReporter.name],
            list: [
                {
                    name: JunitReporter.name,
                    handler: (...args) => new JunitReporter({ reportPath: "foo/bar.xml" }).boot(...args),
                },
            ],
        },
    })
  3. Run the tests. When the report will be ready, you will find the report saved at the path you have specified.