import {ConsoleReporter} from '@serenity-js/console-reporter/lib/stage/crew/console-reporter'
public class | source

ConsoleReporter

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).

Implements:

Examples:

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

 configure({
     crew: [ ConsoleReporter.withDefaultColourSupport() ],
 });
Registering the reporter using Protractor configuration
 // protractor.conf.js
 const { ConsoleReporter } = require('@serenity-js/console-reporter');

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

   serenity: {
     crew: [
       ConsoleReporter.withDefaultColourSupport(),
     ],
     // other Serenity/JS config
   },

   // other Protractor config
 };

Static Method Summary

Static Public Methods
public static

Instantiates a ConsoleReporter with a colour theme optimised for terminals with dark backgrounds.

public static

Instantiates a ConsoleReporter with a colour theme optimised for terminals with light backgrounds.

public static

Instantiates a ConsoleReporter with a monochromatic colour theme.

public static

Instantiates a ConsoleReporter that auto-detects your terminal's support for colours and use 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.

Constructor Summary

Public Constructor
public

constructor(printer: Printer, theme: TerminalTheme, stage: Stage)

Method Summary

Public Methods
public

Creates a new instance of this StageCrewMember and assigns it to a given Stage.

public

notifyOf(event: DomainEvent): void

Handles DomainEvent objects emitted by the StageCrewMember.

Static Public Methods

public static forDarkTerminals(): ConsoleReporter source

Instantiates a ConsoleReporter with a colour theme optimised for terminals with dark backgrounds.

Returns:

ConsoleReporter

public static forLightTerminals(): ConsoleReporter source

Instantiates a ConsoleReporter with a colour theme optimised for terminals with light backgrounds.

Returns:

ConsoleReporter

public static forMonochromaticTerminals(): ConsoleReporter source

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

Returns:

ConsoleReporter

public static withDefaultColourSupport(): ConsoleReporter source

Instantiates a ConsoleReporter that auto-detects your terminal's support for colours and use 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.

If the above describes your setup, use ConsoleReporter#forDarkTerminals or ConsoleReporter#forLightTerminals to make the sub-process produce colour output.

Returns:

ConsoleReporter

Public Constructors

public constructor(printer: Printer, theme: TerminalTheme, stage: Stage) source

Params:

NameTypeAttributeDescription
printer Printer
theme TerminalTheme
stage Stage
  • optional
  • default: null

Public Methods

public assignedTo(stage: Stage): StageCrewMember source

Creates a new instance of this StageCrewMember and assigns it to a given Stage.

Params:

NameTypeAttributeDescription
stage Stage

An instance of a Stage this StageCrewMember will be assigned to

Returns:

StageCrewMember

A new instance of this StageCrewMember

public notifyOf(event: DomainEvent): void source

Handles DomainEvent objects emitted by the StageCrewMember.

Params:

NameTypeAttributeDescription
event DomainEvent

Returns:

void

Listens:

DomainEvent