Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jasmine-expect

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jasmine-expect

Additional matchers for the Jasmine BDD JavaScript testing library

  • 2.0.0-beta3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
38K
decreased by-18.73%
Maintainers
1
Weekly downloads
 
Created
Source

Jasmine-Matchers

Readable tests.

Build Status npm downloads Code Climate Coverage Twitter Follow @fold_left on Twitter GitHub stars GitHub followers

Contents

Purpose

The Jasmine testing framework from Pivotal Labs comes with this default set of matchers;

expect(fn).toThrow(e);
expect(instance).toBe(instance);
expect(mixed).toBeDefined();
expect(mixed).toBeFalsy();
expect(number).toBeGreaterThan(number);
expect(number).toBeLessThan(number);
expect(mixed).toBeNull();
expect(mixed).toBeTruthy();
expect(mixed).toBeUndefined();
expect(array).toContain(member);
expect(string).toContain(substring);
expect(mixed).toEqual(mixed);
expect(mixed).toMatch(pattern);

Using the default Matchers your tests and failure output might look something like this;

it('should expose the expected API', function() {
  expect(typeof record.save).toEqual('function');
});

Expected "undefined" to equal "function"

it('should distribute evenly', function() {
  expect(basket.items % 2 === 0).toEqual(true);
});

Expected false to equal true

Using Jasmine-Matchers the same tests and failure output can be written like this;

it('should expose the expected API', function() {
  expect(record).toHaveMethod('save');
});

Expected member "save" of { save : undefined } to be function.

it('should distribute evenly', function() {
  expect(basket).toHaveEvenNumber('items');
});

Expected member "items" of { items : 25 } to be even number.

Installation

npm

npm install jasmine-expect --save-dev

Bower

bower install jasmine-expect --save-dev

Manual

Downloads are available on the releases page.

Integration

Browser

Include Jasmine Matchers after Jasmine but before your tests.

<script src="/path/to/jasmine-matchers.js"></script>

Karma

Integration is easy with the karma-jasmine-matchers plugin.

Node.js

When using jasmine-node 1.x, provide the path to where Jasmine Matchers is installed as the value for --requireJsSetup.

jasmine-node --requireJsSetup node_modules/jasmine-expect/index.js test

jasmine-node 2.x has no such hooks that I'm aware of for loading helpers, in this case the following call is needed before the first test in your suite.

require('jasmine-expect');

Sublime Text

Jasmine-Matchers-Snippets can be installed with Package Control to ease development with Jasmine Matchers in Sublime Text.

Tern

Plugin for Tern to auto-complete matchers in supported editors.

Available Matchers

Arrays

Booleans

Dates

Functions and Errors

Numbers

Objects

Strings

Known Supported Devices

During development, Jasmine-Matchers is tested against the following environments.

  • Chrome 40.0.2214 (Mac OS X 10.10.1)
  • Firefox 33.0.0 (Mac OS X 10.10)
  • IE 7 (Windows XP on VirtualBox)
  • IE 8 (Windows XP on VirtualBox)
  • IE 9 (Windows 7 on VirtualBox)
  • IE 10 (Windows 7 on VirtualBox)
  • IE 11 (Windows 8.1 on SauceLabs)
  • Opera 27.0.1689 (Mac OS X 10.10.1)
  • Opera Mobile (Amazon Kindle Fire HD 8.9 on Opera Mobile Emulator)
  • PhantomJS 1.9.8 (Mac OS X)
  • Safari 8.0.2 (Mac OS X 10.10.1)

Keywords

FAQs

Package last updated on 31 Jan 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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc