node package manager
Don’t reinvent the wheel. Reuse code within your team. Create a free org »

jasmine-console-reporter

jasmine-console-reporter

npm release downloads dependencies license maintained

© 2017, Onur Yıldırım (@onury). MIT License.

Console Reporter for Jasmine. Outputs detailed test results to the console, with beautiful layout and colors. This is the default reporter of grunt-jasmine-nodejs.

Example output:

Example Screenshot

Installation

npm install jasmine-console-reporter --save-dev

Jasmine Console Reporter version 2+ requires Node.js v4 or newer. For older, you can install jasmine-console-reporter@1.2.7

Usage

const JasmineConsoleReporter = require('jasmine-console-reporter');
const reporter = new JasmineConsoleReporter({
    colors: 1,           // (0|false)|(1|true)|2 
    cleanStack: 1,       // (0|false)|(1|true)|2|3 
    verbosity: 4,        // (0|false)|1|2|(3|true)|4 
    listStyle: 'indent', // "flat"|"indent" 
    activity: false
});
// pass the initialized reporter to whichever task or host... 

Options

Option Description

colors

Number\|Boolean
Default: 1. Specifies whether the output should have colored text. Possible integer values: 0 to 2. Set to 1 (or true) to enable colors. Set to 2 to use the ANSI escape codes. Option 2 can be useful if, for example, you're running your tests from a sub-process, and the colors aren't showing up.

cleanStack

Number\|Boolean
Default: 1. Specifies the filter level for the error stacks. Possible integer values: 0 to 3. Set to 1 (or true) to only filter out lines with jasmine-core path from stacks. Set to 2 to filter out all node_modules paths. Set to 3 to also filter out lines with no file path in it.

verbosity

Number\|Boolean
Default: 4. Specifies the verbosity level for the reporter output. Possible integer values: 0 to 4. When a Boolean value is passed, true defaults to 4 and false defaults to 0. Level 0: reports errors only. Level 1: also displays a summary. Level 2: also reports pending specs. Level 3: additionally displays all suites and specs as a list, except disabled specs. Level 4: also lists disabled specs. (alias: verbose)

listStyle

String
Default: "indent". Indicates the style of suites/specs list output. Possible values: "flat" or "indent". Setting this to "indent" provides a better view especially when using nested (describe) suites. This option is only effective when verbosity level is set to 3, 4 or true.

activity

Boolean
Default: false. Specifies whether to enable the activity indicator animation that outputs the current spec that is being executed. If your tests log extra data to console, this option should be disabled or they might be overwritten.

Full Example with Jasmine (Node.js)

#!/usr/bin/env node
 
// setup Jasmine 
const Jasmine = require('jasmine');
const jasmine = new Jasmine();
jasmine.loadConfig({
    spec_dir: 'test',
    spec_files: ['**/*[sS]pec.js'],
    helpers: ['helpers/**/*.js'],
    random: false,
    seed: null,
    stopSpecOnExpectationFailure: false
});
jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 15000;
 
// setup console reporter 
const JasmineConsoleReporter = require('jasmine-console-reporter');
const reporter = new JasmineConsoleReporter({
    colors: 1,           // (0|false)|(1|true)|2 
    cleanStack: 1,       // (0|false)|(1|true)|2|3 
    verbosity: 4,        // (0|false)|1|2|(3|true)|4 
    listStyle: 'indent', // "flat"|"indent" 
    activity: false
});
 
// initialize and execute 
jasmine.env.clearReporters();
jasmine.addReporter(reporter);
jasmine.execute();

Change-Log

See CHANGELOG.md.

License

See MIT.