Skip to main content

publicexternalConsoleReporter

A StageCrewMember that uses standard output to report on progress of your Serenity/JS acceptance tests.

ConsoleReporter ships with colour themes for both dark and light terminals, as well as a monochromatic theme for those moments when you're in a noir mood (or have a terminal that doesn't support colours, like the good old cmd.exe on Windows).

Registering Console Reporter programmatically

 import { configure } from '@serenity-js/core';
import { ConsoleReporter } from '@serenity-js/console-reporter';

configure({
crew: [
ConsoleReporter.withDefaultColourSupport()
],
});

Redirecting output to a file

 import { configure } from '@serenity-js/core';
import { ConsoleReporter } from '@serenity-js/console-reporter';
import { createWriteStream } from 'fs';

configure({
outputStream: createWriteStream('./output.log'),
crew: [ ConsoleReporter.withDefaultColourSupport() ],
});

Registering Console Reporter with Playwright Test

// playwright.config.ts
import { devices } from '@playwright/test';
import type { PlaywrightTestConfig } from '@serenity-js/playwright-test';

const config: PlaywrightTestConfig = {

reporter: [
[ 'line' ],
[ 'html', { open: 'never' } ],
[ '@serenity-js/playwright-test', {
crew: [
'@serenity-js/console-reporter',
]
}]
],
}

Registering Console Reporter with WebdriverIO

// wdio.conf.ts
import { ConsoleReporter } from '@serenity-js/console-reporter';
import { WebdriverIOConfig } from '@serenity-js/webdriverio';

export const config: WebdriverIOConfig = {

framework: '@serenity-js/webdriverio',

serenity: {
crew: [
'@serenity-js/console-reporter',
]
// other Serenity/JS config
},

// other WebdriverIO config
}

Registering Console Reporter with Protractor

// protractor.conf.js
const { ConsoleReporter } = require('@serenity-js/console-reporter');

exports.config = {
framework: 'custom',
frameworkPath: require.resolve('@serenity-js/protractor/adapter'),

serenity: {
crew: [
'@serenity-js/console-reporter',
],
// other Serenity/JS config
},

// other Protractor config
}

Changing the default colour theme

  // ...
serenity: {
crew: [
[ '@serenity-js/console-reporter', {
theme: 'light',
// theme: 'dark',
// theme: 'mono',
// theme: 'auto',
} ]
],
},
//...

Implements

Index

Constructors

externalconstructor

  • Parameters

    • externalprinter: Printer
    • externaltheme: TerminalTheme
    • externaloptionalstage: Stage

    Returns ConsoleReporter

Methods

staticexternalfromJSON

staticexternalwithDefaultColourSupport

  • Instantiates a ConsoleReporter that auto-detects your terminal's support for colours and uses a colour theme for dark terminals if successful.

    Please note that spawning your test process from another process (by using npm-failsafe, for example) causes the ConsoleReporter to use the monochromatic colour scheme, as colour support can't be detected in child processes.


    Returns StageCrewMemberBuilder<ConsoleReporter>

staticexternalforMonochromaticTerminals

  • Instantiates a ConsoleReporter with a monochromatic colour theme. Good for terminals with no colour support (like the cmd.exe on Windows), or for times when you need to pipe the output to a text file and want to avoid printing control characters.


    Returns StageCrewMemberBuilder<ConsoleReporter>

staticexternalforDarkTerminals

staticexternalforLightTerminals

externalnotifyOf