You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

jasmine-matcher-errors

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jasmine-matcher-errors

Customize the error message reported by a custom jasmine matcher.

1.0.0
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

jasmine-matcher-errors

Customize the error message reported by a custom jasmine matcher.

Why?

The message returned by a custom jasmine matcher is duplicated into the error object created for the failed spec. This results in error messages always being output twice.

screenshot from 2016-06-01 09-04-53

Once you can customize the error message you could keep the message brief, and put more detailed information in the error message, or whatever makes sense for your custom matcher.

screenshot from 2016-06-01 09-05-56

Setup

jasmine-node

  • Node + npm
  • Install from npm.
  • npm install --save-dev jasmine-matcher-errors
  • Include in your custom matchers.
  • require('jasmine-matcher-errors')

jasmine

  • Install from bower.
  • bower install --save-dev jasmine-matcher-errors
  • Include before your custom matchers.
  • <script type="text/javascript" src="bower_components/jasmine-matcher-errors/src/index.js"></script>

Usage

Simply add an error object to the return object of your custom matcher.

jasmine.addMatchers({
  exampleMatcher: function() {
    return {
      compare: function(actual, expected) {
        ...
        return {
          pass: pass,
          message: message,
          error: new Error(message + '\n\n' + details)
        };
      }
    };
  }
});

Keywords

jasmine

FAQs

Package last updated on 01 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts