Socket
Socket
Sign inDemoInstall

jasmine-matcher-errors

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jasmine-matcher-errors

Customize the error message reported by a custom jasmine matcher.


Version published
Maintainers
1
Install size
4.65 kB
Created

Readme

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

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

jasmine

  1. Install from bower.
  • bower install --save-dev jasmine-matcher-errors
  1. 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

FAQs

Last updated on 01 Jun 2016

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc