1.0.3 • Published 7 years ago

jasmine-add-matcher v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
7 years ago

Alternate API for adding custom Jasmine matchers

This is a more declarative, and, I hope, easier to use API for writing custom Jasmime matchers.

Documentation

Instead of this:

// TODO

use this:

let jenh = require('jasmine-add-matcher');
beforeEach(function () {
  jenh.addMatcher('toBeEven', 'expected {actual} (NOT) to be even', (actual) => actual % 2 === 0);
});
it('works', function () {
  expect(3).toBeEven();
});

More stuff

type CheckFunction = (actual: any, expected: any, util: Object, customEqualityTester: Object) => boolean
type FormatFunction = (actual: any, expected: any, util: Object) => string

declare function matcher(
    name: string,
    messageTemplates: string | [string, string],
    checkFn: CheckFunction,
    formatValueFn?: FormatFunction
): Matcher;

declare function addMatcher(
    name: string,
    messageTemplates: string | [string, string],
    checkFn: CheckFunction,
    formatValueFn?: FormatFunction
): void;

License

MIT

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago