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

add-matchers

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

add-matchers - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

dist/create-api.d.ts

29

CHANGELOG.md

@@ -1,23 +0,26 @@

<a name="0.5.0"></a>
# [0.5.0](https://github.com/JamieMason/add-matchers/compare/0.4.0...v0.5.0) (2017-03-09)
# [0.6.0](https://github.com/JamieMason/add-matchers/compare/0.5.0...0.6.0) (2018-12-22)
### Features
* **core:** support asymmetric jasmine and jest matchers ([e1e5c18](https://github.com/JamieMason/add-matchers/commit/e1e5c18))
- **npm:** update dependencies
([aa8ca6c](https://github.com/JamieMason/add-matchers/commit/aa8ca6c))
# [0.5.0](https://github.com/JamieMason/add-matchers/compare/0.4.0...0.5.0) (2017-03-09)
### Features
<a name="0.4.0"></a>
- **core:** support asymmetric jasmine and jest matchers
([e1e5c18](https://github.com/JamieMason/add-matchers/commit/e1e5c18))
# [0.4.0](https://github.com/JamieMason/add-matchers/compare/39f4a46...0.4.0) (2017-01-18)
### Features
* **core:** add delegate for adding matchers ([901328b](https://github.com/JamieMason/add-matchers/commit/901328b))
* **jasmine:** add adapter for jasmine 1.x ([39f4a46](https://github.com/JamieMason/add-matchers/commit/39f4a46))
* **jasmine:** add adapter for jasmine 2.x ([20a2545](https://github.com/JamieMason/add-matchers/commit/20a2545))
* **jest:** add adapter for jest ([f419fc7](https://github.com/JamieMason/add-matchers/commit/f419fc7))
- **core:** add delegate for adding matchers
([901328b](https://github.com/JamieMason/add-matchers/commit/901328b))
- **jasmine:** add adapter for jasmine 1.x
([39f4a46](https://github.com/JamieMason/add-matchers/commit/39f4a46))
- **jasmine:** add adapter for jasmine 2.x
([20a2545](https://github.com/JamieMason/add-matchers/commit/20a2545))
- **jest:** add adapter for jest
([f419fc7](https://github.com/JamieMason/add-matchers/commit/f419fc7))
{
"name": "add-matchers",
"description": "Write useful test matchers compatible with Jest and Jasmine.",
"version": "0.5.0",
"version": "0.6.0",
"author": "Jamie Mason (https://github.com/JamieMason)",
"bugs": {
"url": "https://github.com/JamieMason/add-matchers/issues"
},
"bugs": "https://github.com/JamieMason/add-matchers/issues",
"devDependencies": {
"browserify": "13.0.0",
"jasmine": "2.5.3",
"nodemon": "1.11.0",
"xo": "0.17.1"
"@types/jasmine-v1": "npm:@types/jasmine@1.3.3",
"@types/jasmine-v2": "npm:@types/jasmine@2.8.14",
"@types/jest": "23.3.10",
"@types/node": "10.12.18",
"jasmine": "3.3.1",
"jasmine-node": "1.16.2",
"jest": "23.6.0",
"npm-run-all": "4.1.5",
"prettier": "1.15.3",
"rimraf": "2.6.2",
"ts-jest": "23.10.5",
"tslint": "5.12.0",
"typescript": "3.2.2"
},
"files": [
"dist/",
"index.js",
"src/"
"dist"
],

@@ -28,26 +33,16 @@ "homepage": "https://github.com/JamieMason/add-matchers",

"license": "MIT",
"main": "index.js",
"repository": {
"type": "git",
"url": "git://github.com/JamieMason/add-matchers.git"
},
"main": "dist/index.js",
"repository": "JamieMason/add-matchers.git",
"scripts": {
"build": "browserify index.js --standalone addMatchers --outfile dist/add-matchers.js",
"lint": "xo --fix",
"prebuild": "mkdir -p dist",
"prepublish": "npm run build",
"test": "jasmine JASMINE_CONFIG_PATH=jasmine.json",
"watch": "nodemon --quiet --watch src/ --watch index.js ./node_modules/jasmine/bin/jasmine.js JASMINE_CONFIG_PATH=jasmine.json"
},
"xo": {
"envs": [
"jasmine",
"node"
],
"rules": {
"max-nested-callbacks": 0
},
"esnext": false,
"space": 2
"build": "tsc --project .",
"format": "prettier --write '**/*.md' './src/**/*.ts' './test/**/*.js'",
"lint": "tslint --fix --project ./tsconfig.json",
"prebuild": "rimraf ./dist",
"prelint": "npm run format",
"prepack": "npm run build",
"test": "run-p 'test:*'",
"test:jasmine-v1": "jasmine-node ./test/e2e.spec.js",
"test:jasmine-v2": "jasmine JASMINE_CONFIG_PATH=jasmine.json",
"test:jest": "jest"
}
}

@@ -9,14 +9,21 @@ # add-matchers

|**What**|A JavaScript library to write test Matchers compatible with all versions of [Jest](http://facebook.github.io/jest/) and [Jasmine](https://jasmine.github.io/).|
|---|:---|
|**Why**|The way you write tests in Jasmine and Jest is _extremely_ similar, but the APIs for adding custom matchers vary wildly between Jasmine 1.x, Jasmine 2.x, and Jest. This library aims to remove those obstacles and encourage Developers to share useful matchers they've created with the community.|
|**How**|Developers use the API from this library, which converts them to be compatible with whichever test framework is running.|
**What**: A JavaScript library to write test Matchers compatible with all
versions of [Jest](http://facebook.github.io/jest/) and
[Jasmine](https://jasmine.github.io/).
**Why**: The way you write tests in Jasmine and Jest is _extremely_ similar, but
the APIs for adding custom matchers vary wildly between Jasmine 1.x, Jasmine
2.x, and Jest. This library aims to remove those obstacles and encourage
Developers to share useful matchers they've created with the community.
**How**: Developers use the API from this library, which converts them to be
compatible with whichever test framework is running.
## Contents
* [Installation](#installation)
* [API](#api)
* [Writing Matchers](#writing-matchers)
* [Examples](#examples)
* [Related Projects](#related-projects)
- [Installation](#installation)
- [API](#api)
- [Writing Matchers](#writing-matchers)
- [Examples](#examples)
- [Related Projects](#related-projects)

@@ -29,26 +36,47 @@ ## Installation

Include add-matchers after your test framework but before your tests, and register your matchers before your tests as well.
Include add-matchers after your test framework but before your tests, and
register your matchers before your tests as well.
## API
```
var addMatchers = require('add-matchers');
### Add Custom Matchers
```js
import { addMatchers } from 'add-matchers';
addMatchers({
toBeFoo: function() {},
toBeBar: function() {}
toBeFoo(value) {
return value === 'foo';
},
toInclude(other, value) {
return value.includes(other);
}
});
```
// expect('foo').toBeFoo();
// expect('bar').toBeBar();
```js
expect('foo').toBeFoo();
expect('jamie').toInclude('jam');
```
### Add Custom Asymmetric Matchers
```js
import { addMatchers } from 'add-matchers';
addMatchers.asymmetric({
foo: function() {},
bar: function() {}
toBeFoo(value) {
return value === 'foo';
},
toInclude(other, value) {
return value.includes(other);
}
});
```
// expect({ key: 'foo', prop: 'bar' }).toEqual({
// key: any.foo(),
// prop: any.bar()
// });
```js
expect({ key: 'foo', prop: 'bar' }).toEqual({
key: any.toBeFoo(),
prop: any.toInclude('ar')
});
```

@@ -58,7 +86,13 @@

The argument passed to `expect` is always the last argument passed to your Matcher, with any other arguments appearing before it in the order they were supplied.
The argument passed to `expect` is always the last argument passed to your
Matcher, with any other arguments appearing before it in the order they were
supplied.
This means that, in the case of `expect(received).toBeAwesome(arg1, arg2, arg3)`, your function will be called with `fn(arg1, arg2, arg3, received)`.
This means that, in the case of
`expect(received).toBeAwesome(arg1, arg2, arg3)`, your function will be called
with `fn(arg1, arg2, arg3, received)`.
Arguments are ordered in this way to support [partial application](http://ejohn.org/blog/partial-functions-in-javascript/) and increase re-use of matchers.
Arguments are ordered in this way to support
[partial application](http://ejohn.org/blog/partial-functions-in-javascript/)
and increase re-use of matchers.

@@ -83,3 +117,3 @@ ### Examples

```js
var addMatchers = require('add-matchers');
import { addMatchers } from 'add-matchers';

@@ -113,9 +147,16 @@ addMatchers({

For more examples, see [Jasmine Matchers](https://github.com/JamieMason/Jasmine-Matchers/tree/master/src) which is built using this library.
For more examples, see
[Jasmine Matchers](https://github.com/JamieMason/Jasmine-Matchers/tree/master/src)
which is built using this library.
## Related Projects
+ [Jasmine Matchers](https://github.com/JamieMason/Jasmine-Matchers): A huge library of test assertion matchers to improve readability.
+ [karma-benchmark](https://github.com/JamieMason/karma-benchmark): A Karma plugin to run [Benchmark.js](https://benchmarkjs.com/) over multiple browsers, with CI compatible output.
+ [karma-jasmine-matchers](https://github.com/JamieMason/karma-jasmine-matchers): A Karma plugin to inject Jasmine Matchers.
+ [karma-nested-reporter](https://github.com/JamieMason/karma-nested-reporter): Easy to read test output with nested `describe` and `it` blocks.
- [Jasmine Matchers](https://github.com/JamieMason/Jasmine-Matchers): A huge
library of test assertion matchers to improve readability.
- [karma-benchmark](https://github.com/JamieMason/karma-benchmark): A Karma
plugin to run [Benchmark.js](https://benchmarkjs.com/) over multiple browsers,
with CI compatible output.
- [karma-jasmine-matchers](https://github.com/JamieMason/karma-jasmine-matchers):
A Karma plugin to inject Jasmine Matchers.
- [karma-nested-reporter](https://github.com/JamieMason/karma-nested-reporter):
Easy to read test output with nested `describe` and `it` blocks.
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