パッケージの詳細

jasmine-console-reporter

onury69.2kMIT3.1.0

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.

jasmine, console, reporter, report

readme

jasmine-console-reporter

npm release license downloads dependencies maintained

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

Progressive Console Reporter for Jasmine. (for Jasmine v3+)
Outputs detailed test results to the console, with beautiful layout and colors.

Example screen:

JCR Screen

Overall summary outputs:

JCR Summaries

Installation

npm i jasmine-console-reporter --save-dev

JCR v3+ requires peer dependency Jasmine v3+ and works on Node.js v6+. See compatibility table.

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|Object
    listStyle: 'indent', // "flat"|"indent"
    timeUnit: 'ms',      // "ms"|"ns"|"s"
    timeThreshold: { ok: 500, warn: 1000, ouch: 3000 }, // Object|Number
    activity: false,     // boolean or string ("dots"|"star"|"flip"|"bouncingBar"|...)
    emoji: true,
    beep: true
});
// 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\ Object` 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 and excluded specs. Level 4: lists all. Or set to an object to toggle each output section individually. Any omitted value will default to true. e.g. { pending: false, disabled: false, specs: false, summary: true }

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.

timeUnit

String
Default: "ms". Specifies the time unit to be used to measure spec execution. "ms" for milliseconds, "ns" for milliseconds including hi-res nanoseconds remainder, "s" for seconds including milliseconds remainder. Note that overall time in final summary is always reported in seconds.

timeThreshold

`Number
Object` Default: { ok: 500, warn: 1000, ouch: 3000 }. Specifies the expected maximum time(s) (in milliseconds) for any spec to complete its execution. If threshold is exceeded, elapsed time for that spec will be accented in the output. This is only effective if colors option is enabled.

activity

`Boolean\
String` Default: false. Specifies whether to enable the activity indicator animation that outputs the current spec that is being executed. Set to a string value to set/change the spinner style.

emoji

`Boolean\
Object` Default: false. Whether to output some emojis within the report, for a little fun. To customize emojis, you can set an object. Note that emojis will be auto-disabled in CI environments.

beep

Boolean
Default: true. Whether to play system beep when tests finish with status "failed". Note that beep will be auto-disabled in CI and non-TTY environments.

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|Object
    listStyle: 'indent', // "flat"|"indent"
    timeUnit: 'ms',      // "ms"|"ns"|"s"
    timeThreshold: { ok: 500, warn: 1000, ouch: 3000 }, // Object|Number
    activity: true,
    emoji: true,         // boolean or emoji-map object
    beep: true
});

// initialize and execute
jasmine.env.clearReporters();
jasmine.addReporter(reporter);
jasmine.execute();

Change-Log

See CHANGELOG.md.

Compatibility Table

Jasmine Console Reporter Node Jasmine
v3.x v6 and newer v3.x
v2.x v4 and newer v2.x
v1.2.7 below v4 v2.x

License

MIT.

更新履歴

Jasmine Console Reporter Changelog

All notable changes to this project will be documented in this file. The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

3.1.0 (2018-08-21)

Added

  • Execution elapsed time for each spec. #11
  • New option: timeUnit (String, default: "ms") The time unit to be used to measure spec execution. "ms" for milliseconds, "ns" for milliseconds including hi-res nanoseconds remainder, "s" for seconds including milliseconds remainder.
  • New option: timeThreshold (Object|Number, default: { ok: 500, warn: 1000, ouch: 3000 }) the expected maximum time(s) (in milliseconds) for any spec to complete its execution. If threshold is exceeded, elapsed time for that spec will be accented in the output. This is only effective if colors option is enabled.
  • verbosity option now also accepts an object, in order to toggle each output section individually. #11

Changed

  • Updated dependencies to latest versions.

Fixed

  • An issue where some options (such as colors) would not pick up default values when omitted. Fixes #10.

3.0.2 (2018-05-17)

Changed

  • Randomness and random seed displayed if running in random order and verbosity is 1 or above. PR #9 by @steverice.
  • Updated dependencies to latest versions.

3.0.0 (2018-04-03)

This major version is re-written in ES2015. See breaking changes below.

Added

  • Support for Jasmine v3+ (peer-dependency). Also see Jasmine v3 changes.
  • Additional information is displayed, if running in random order and verbosity is set to 4.
  • Overall status (and reason if status is incomplete) within report summary.
  • Support for non-interactive output terminals. (This allows piping output to a file.)
  • New option: emoji 👊 (boolean, default: false). Note: emojis will be auto-disabled in CI environments.
  • New option: beep (boolean, default: false). Note: beep will be auto-disabled in CI and non-TTY environments.
  • Activity spinner styles. Instead of setting to true, set activity option to a string value to set the style of the spinner. e.g. "dots" (default) or "bouncingBar". See all possible values here.

Changed

  • BREAKING: Requires Node.js v6 or newer.
  • Improved exception stack parsing.
  • Better activity spinner.

Fixed

  • An issue where exception message is not printed before the stack. Fixes #7 & #8.

2.0.1 (2017-08-20)

Changed

  • Breaking: Due to chalk dependency upgrade, the reporter now requires Node.js v4 or newer.
  • Extensive code revision.

Fixed

  • An issue where the reporter would crash when colors option is set to 2 (ANSI colors). Fixes issue #5.

1.2.8 (2017-08-20)

(CAUTION: version 1.2.8 has a critical bug. To avoid it, do NOT set colors option to 2 (ANSI colors). Or better update to v2+ if you're using Node.js version 4 or newer.)

Changed

  • Updated jasmine and chalk to latest versions.
  • Clean-up.

1.2.7 (2016-08-21)

Fixed

  • An issue with cleanStack option, that would render the first line as the error message, not respecting messages with \n (new-line) in them.

Changed

  • Updated dev-dependencies.

1.2.6 (2016-05-09)

Fixed

  • An issue with failed specs that don't have an error stack, would not output a warning message.

Changed

  • Updated dependencies to their latest versions.

1.2.4 (2016-03-18)

Added

  • Support for ANSI escape codes, for colors option. (PR #1 by @msrose)

1.2.2 (2016-02-27)

Added

  • Grunt, jasmine tests, etc...

Changed

  • Moved helper classes and utils to separate modules.

1.2.0 (2016-02-26)

Changed

  • Moved the reporter to its own repo.
  • Code revisions and clean-up.

1.1.3 (2015-07-05)

Changed

  • Expanded verbosity levels (0 to 4). Setting to 3 will not report disabled specs anymore while listing others. Set to 4 (default) for the most verbose report.
  • Updated dependencies to their latest versions.

1.1.0 (2015-05-01)

Changed

  • Updated dependencies.
  • Minor code revisions and clean-up.

1.0.1 (2015-04-27)

Changed

  • The default value of activity option is now false. This should not be enabled if your tests log extra data to console. Fixed activity output.

1.0.0 (2015-04-21)

Added

  • Progressive console output. Each spec result is now output at real-time as it's executed. This effectively helps tracking unhandled errors.
  • Highlighting for file name, line and column numbers in stacks. Only effective if colors is enabled.
  • New option: listStyle. See documentation.
  • Support for clickable file paths in error stacks (This is useful only if your terminal supports it. For example, <kbd>CMD</kbd>+<kbd>Click</kbd> will open the file and move the cursor to the target line in iTerm 2 for Mac, if configured.)
  • New option: activity. See documentation.

Changed

  • cleanStack option now also accepts a Number (integer) to determine the filter level. verbosity option now also accepts a Number (integer) to determine the verbosity level.
  • Updated dependencies to their latest versions.

Fixed

  • Mis-handled nested suites (describe blocks). Each spec result and nested suite is now correctly output in relation to its parent test siute.
  • An issue with the stack-filter. Now also supports Windows file paths.

Pre-Releases:

0.7.2 (2015-03-11)

Fixed

  • The undefined suite description issue for focused specs (fit(...)); which was breaking the spec-run.

0.7.1 (2015-03-06)

Fixed

  • An issue with displaying symbols and colors for Windows platforms.

0.7.0 (2015-03-04)

Added

  • New option: cleanStack.

Changed

  • Code revisions and clean-up.

0.6.3 (2015-03-03)

Fixed

  • null stack trace issue & peer jasmine-core. (PR by @fiznool)

0.6.2 (2015-03-01)

Changed

  • Improved reporter output.
  • Code clean-up.

0.6.0 (2015-02-12)

Changed

  • Cleaner error stacks. Filtered out lines with jasmine-core path.
  • Better reporter console output.

0.5.1 (2015-02-07)

Fixed

  • Timer (zero elapsed time) issue.

0.5.0 (2015-02-07)

Initial release.