Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

jasmine-line-per-spec-reporter

whatware11MIT0.3.0

Always report one line per spec, regardless of spec status.

reporter, spec, line, single, jasmine

readme

jasmine-line-per-spec-reporter 0.3.0 (2016-04-20)

Always report one line per spec, regardless of spec status.

Provided as a reporter class for the jasmine test framework.

Example

The output format is:

status-right-padded - spec-number-left-padded/total-spec-count - full suite/spec description
                                                                 indented expect messages
                                                                 are output on FAILURE

Such that output would look like:

Passed   -   1/4 - Suite one Sub-suite AAA Spec one
FAILED   -   2/4 - Suite one Sub-suite BBB Spec two
                   Expected 1 to be 0.

Pending  -   3/4 - Suite one Sub-suite BBB Spec three
Disabled -   4/4 - Suite one Sub-suite CCC Spec four

Given these suites/specs:

describe('Suite one', () => {
    describe('Sub-suite AAA', () => {
        it('Spec one', () => {
            expect(0).toBe(0);
        });
    });

    describe('Sub-suite BBB', () => {
        it('Spec two', () => {
            expect(1).toBe(0);
        });

        xit('Spec three', () => {
            expect(0).toBe(0);
        });
    });

    xdescribe('Sub-suite CCC', () => {
        it('Spec four', () => {
            expect(0).toBe(0);
        });
    });
});

Installation

The easiest way is to keep jasmine-line-per-spec-reporter as a devDependency in your package.json. Just run

npm install jasmine-line-per-spec-reporter --save-dev

to let npm automatically add it there.

Configuration

protractor

In your protractor.conf.js file:

  • At the top, or with the other require lines, add:

      const JasmineLinePerSpecReporter = require('jasmine-line-per-spec-reporter');
  • In the config.onPrepare function, add:

          if (browser.params.linePerSpecReporter === true) {
              jasmine.getEnv().addReporter(new JasmineLinePerSpecReporter(jasmine));
          }
  • You can also hide disabled specs. So, if you're using any fdescribe/fit, or disabling remaining lines on failure, you won't see superfluous Disabled lines. In the config.onPrepare function, add:

          if (browser.params.linePerSpecReporter === true) {
              const conifg = {
                  hideDisabled: true
              };
              jasmine.getEnv().addReporter(new JasmineLinePerSpecReporter(jasmine, config));
          }

    This will produce output like the following:

      Passed   -   1/4 - Suite one Sub-suite AAA Spec one
      FAILED   -   2/4 - Suite one Sub-suite BBB Spec two
                         Expected 1 to be 0.
    
      Pending  -   3/4 - Suite one Sub-suite BBB Spec three
    
      1 disabled spec was hidden
  • You can also see stack trace lines that only match the path to your spec files, without all the extra stack trace junk you get from the default reporter. E.g., If you project root folder is my-project-folder and all your tests are in my-project-folder/test/spec, then in the config.onPrepare function, add:

          if (browser.params.linePerSpecReporter === true) {
              const conifg = {
                  failureExpectationMessageSuffixLine: '',
                  failureSuffixLine: null,
                  showStackTrace: true,
                  showStackTraceRegExMatch: /^.*[\\\/](my-project-folder[\\\/]test[\\\/]spec[\\\/].*)\)$/g,
                  showStackTraceRegExReplace: '  at $1',
                  showStackTraceRegExShowMax: 1
              };
              jasmine.getEnv().addReporter(new JasmineLinePerSpecReporter(jasmine, config));
          }

    This will produce output for each failure showing only the first stack trace line that matches your criteria, like the following:

      Passed   -   1/4 - Suite one Sub-suite AAA Spec one
      FAILED   -   2/4 - Suite one Sub-suite BBB Spec two
                         Expected 1 to be 0.
                         Stack trace (replaced lines):
                           at my-project-folder/test/spec/myTest.js:10:8
    
      Pending  -   3/4 - Suite one Sub-suite BBB Spec three
      Disabled -   4/4 - Suite one Sub-suite CCC Spec four

grunt + protractor

If you are using grunt, this configuration will allow you to specify the protractor flag from the grunt command line.

You must modify the protractor configuration in your Gruntfile.js as:

    protractor: {
        options: {
            args: {
                params: {
                    // Map the `grunt` command line argument:
                    //     --linePerSpecReporter=true
                    // to the `protractor` boolean property:
                    //     browser.params.linePerSpecReporter
                    linePerSpecReporter: grunt.option('linePerSpecReporter')
                }
            }
        }
    }

grunt + regular jasmine

TODO

Usage

protractor

Run your usual protractor command with the extra flag:

--params.linePerSpecReporter=true

e.g.:

protractor --params.linePerSpecReporter=true

grunt

Run your usual grunt command with the extra flag:

--linePerSpecReporter=true

e.g.:

grunt test --linePerSpecReporter=true

TODO

  • Needs documentation -- Until fully documented, see defaultConfig in dist/jasmine-line-per-spec-reporter.js for all of the properties that can be set using optionalConfig as:

              jasmine.getEnv().addReporter(new JasmineLinePerSpecReporter(jasmine, optionalConfig));
  • Feature -- Optional time prefixes:

    • Delta -- time between each spec as SS.mmm, e.g.:

        00.000 Passed   -   1/4 - Suite one Sub-suite AAA Spec one
        00.250 FAILED   -   2/4 - Suite one Sub-suite BBB Spec two
                                  Expected 1 to be 0.
      
        00.133 Pending  -   3/4 - Suite one Sub-suite BBB Spec three
        00.088 Disabled -   4/4 - Suite one Sub-suite CCC Spec four
    • Relative -- time since first spec MM:SS.mmm, e.g.:

        00:00.000 Passed   -   1/4 - Suite one Sub-suite AAA Spec one
        00:00.133 FAILED   -   2/4 - Suite one Sub-suite BBB Spec two
                                     Expected 1 to be 0.
      
        00:00.250 Pending  -   3/4 - Suite one Sub-suite BBB Spec three
        00:00.250 Disabled -   4/4 - Suite one Sub-suite CCC Spec four
    • Current -- current time as YYYY-MM-DD HH:MM:SS.mmm, e.g.:

        2016-04-19 16:00:00.000 Passed   -   1/4 - Suite one Sub-suite AAA Spec one
        2016-04-19 16:00:00.133 FAILED   -   2/4 - Suite one Sub-suite BBB Spec two
                                                   Expected 1 to be 0.
      
        2016-04-19 16:00:00.250 Pending  -   3/4 - Suite one Sub-suite BBB Spec three
        2016-04-19 16:00:00.250 Disabled -   4/4 - Suite one Sub-suite CCC Spec four

Changelog / Release History

See CHANGELOG.md.

changelog

Change Log

All notable changes to this project will be documented in this file.

This change log tries to adhere to Keep a CHANGELOG. This project adheres to Semantic Versioning.

Unreleased/master diff

This section will highlight what has been changed since the last official release.

(This project uses a "dirty trunk" -- i.e., all commits are made against "master". When a release is ready, it's made from "master".)

0.3.0 (2016-04-20) diff

Features

  • Hide disabled specs

Added

  • Hide disabled specs -- Optional cability to hide all disabled specs; instead shows count of disabled specs at the end
  • Documentation -- Hide disabled specs

0.2.0 (2016-04-19) diff

Features

  • Stack trace

Added

  • Stack trace -- Optional cability to show only those lines that match a provided regular expression
  • Documentation -- Stack trace. Some new TODOs

Changed

  • Refactored code to be more modular -- There are now private methods to handle the "expectation" and "stack trace" output
  • Documentation -- Some cleanup

0.1.0 (2016-04-18)

Features

  • Initial release

Added

  • Everything

Changed

n/a

Deprecated

n/a

Removed

n/a

Fixed

n/a