Socket
Socket
Sign inDemoInstall

jest-extended

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-extended - npm Package Compare versions

Comparing version 0.10.0 to 0.11.0

dist/matchers/toReject/index.js

29

dist/matchers/index.js

@@ -205,14 +205,26 @@ 'use strict';

var _index50 = require('./toSatisfy/index.js');
var _index50 = require('./toReject/index.js');
var _toSatisfyIndexJs = _interopRequireWildcard(_index50);
var _toRejectIndexJs = _interopRequireWildcard(_index50);
var _index51 = require('./toSatisfyAll/index.js');
var _index51 = require('./toResolve/index.js');
var _toSatisfyAllIndexJs = _interopRequireWildcard(_index51);
var _toResolveIndexJs = _interopRequireWildcard(_index51);
var _index52 = require('./toStartWith/index.js');
var _index52 = require('./toSatisfy/index.js');
var _toStartWithIndexJs = _interopRequireWildcard(_index52);
var _toSatisfyIndexJs = _interopRequireWildcard(_index52);
var _index53 = require('./toSatisfyAll/index.js');
var _toSatisfyAllIndexJs = _interopRequireWildcard(_index53);
var _index54 = require('./toStartWith/index.js');
var _toStartWithIndexJs = _interopRequireWildcard(_index54);
var _index55 = require('./toThrowWithMessage/index.js');
var _toThrowWithMessageIndexJs = _interopRequireWildcard(_index55);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

@@ -270,7 +282,10 @@

'./toIncludeSameMembers/index.js': _toIncludeSameMembersIndexJs,
'./toReject/index.js': _toRejectIndexJs,
'./toResolve/index.js': _toResolveIndexJs,
'./toSatisfy/index.js': _toSatisfyIndexJs,
'./toSatisfyAll/index.js': _toSatisfyAllIndexJs,
'./toStartWith/index.js': _toStartWithIndexJs
'./toStartWith/index.js': _toStartWithIndexJs,
'./toThrowWithMessage/index.js': _toThrowWithMessageIndexJs
};
exports.default = Object.keys(imports).map(key => imports[key]).reduce((acc, matcher) => _extends({}, acc, matcher.default), {});
{
"name": "jest-extended",
"version": "0.10.0",
"version": "0.11.0",
"description": "Additional Jest matchers",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -67,2 +67,3 @@ <div align="center">

- [.toBeFunction()](#tobefunction)
- [.toThrowWithMessage()](#tothrowwithmessagetype-message)
- [Mock](#mock)

@@ -97,3 +98,5 @@ - [.toHaveBeenCalledBefore()](#tohavebeencalledbefore)

- [.toBeSealed()](#tobesealed)
- [~~Promise~~](#promise)
- [Promise](#promise)
- [.toResolve()](#toresolve)
- [.toReject()](#toreject)
- [String](#string)

@@ -185,3 +188,3 @@ - [.toBeString()](#tobestring)

Use `.toBeEmpty` when checking if a `String` `''`, `Array` `[]`, `Object` `{}`, or `[Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#Built-in_iterables)` is empty. Because `toBeEmpty` supports checking for emptiness of Iterables, you can use it to check whether a `Map`, or `Set` is empty, as well as checking that a generator yields no values.
Use `.toBeEmpty` when checking if a `String` `''`, `Array` `[]`, `Object` `{}`, or `[Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#Built-in_iterables)` is empty. Because `toBeEmpty` supports checking for emptiness of Iterables, you can use it to check whether a `Map`, or `Set` is empty, as well as checking that a generator yields no values.

@@ -415,2 +418,26 @@ ```js

#### .toThrowWithMessage(type, message)
Use `.toThrowWithMessage` when checking if a callback function throws an error with a given error type and given error message. Message can either be a `String` or a `RegExp`.
```js
test('throws an error of type TypeError with message "hello world"', () => {
expect(() => {
throw TypeError("hello world");
}).toThrowWithMessage(TypeError, "hello world");
expect(() => {
throw TypeError("hello world");
}).toThrowWithMessage(TypeError, /hello world/);
expect(() => {
throw TypeError("hello world 2");
}).not.toThrowWithMessage(TypeError, "hello world");
expect(() => {
throw TypeError("hello world 2");
}).not.toThrowWithMessage(TypeError, /hello world/);
});
```
### Mock

@@ -770,6 +797,24 @@

### ~~Promise~~
### Promise
_No APIs proposed yet_
#### .toResolve()
Use `.toResolve` when checking if a promise is resolved.
```js
test('passes when a promise resolves', async () => {
await expect(Promise.resolve()).toResolve();
});
```
#### .toReject()
Use `.toReject` when checking if a promise is rejected.
```js
test('passes when a promise rejects', async () => {
await expect(Promise.reject()).toReject();
});
```
### String

@@ -882,3 +927,3 @@

| [<img src="https://avatars0.githubusercontent.com/u/615334?v=4" width="100px;"/><br /><sub>Frederick Fogerty</sub>](https://github.com/frederickfogerty)<br />[πŸ’»](https://github.com/mattphillips/jest-extended/commits?author=frederickfogerty "Code") [πŸ€”](#ideas-frederickfogerty "Ideas, Planning, & Feedback") | [<img src="https://avatars1.githubusercontent.com/u/10714808?v=4" width="100px;"/><br /><sub>Benjamin Kay</sub>](https://github.com/benjaminkay93)<br />[πŸ’»](https://github.com/mattphillips/jest-extended/commits?author=benjaminkay93 "Code") [πŸ“–](https://github.com/mattphillips/jest-extended/commits?author=benjaminkay93 "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/868844?v=4" width="100px;"/><br /><sub>Gilles De Mey</sub>](https://demey.io)<br />[πŸ’»](https://github.com/mattphillips/jest-extended/commits?author=gillesdemey "Code") [πŸ“–](https://github.com/mattphillips/jest-extended/commits?author=gillesdemey "Documentation") [⚠️](https://github.com/mattphillips/jest-extended/commits?author=gillesdemey "Tests") | [<img src="https://avatars0.githubusercontent.com/u/50928?v=4" width="100px;"/><br /><sub>Deniz Dogan</sub>](https://github.com/denizdogan)<br />[πŸ’»](https://github.com/mattphillips/jest-extended/commits?author=denizdogan "Code") | [<img src="https://avatars1.githubusercontent.com/u/13043635?v=4" width="100px;"/><br /><sub>Mikey Powers</sub>](https://github.com/mvpowers)<br />[πŸ’»](https://github.com/mattphillips/jest-extended/commits?author=mvpowers "Code") [πŸ“–](https://github.com/mattphillips/jest-extended/commits?author=mvpowers "Documentation") [⚠️](https://github.com/mattphillips/jest-extended/commits?author=mvpowers "Tests") | [<img src="https://avatars2.githubusercontent.com/u/26580?v=4" width="100px;"/><br /><sub>Tony Trinh</sub>](https://github.com/tony19)<br />[πŸ’»](https://github.com/mattphillips/jest-extended/commits?author=tony19 "Code") | [<img src="https://avatars2.githubusercontent.com/u/2844046?v=4" width="100px;"/><br /><sub>Nikita Kurpas</sub>](https://github.com/NikitaKurpas)<br />[πŸ’»](https://github.com/mattphillips/jest-extended/commits?author=NikitaKurpas "Code") |
| [<img src="https://avatars1.githubusercontent.com/u/65444?v=4" width="100px;"/><br /><sub>Pete Hodgson</sub>](http://thepete.net)<br />[πŸ’»](https://github.com/mattphillips/jest-extended/commits?author=moredip "Code") |
| [<img src="https://avatars0.githubusercontent.com/u/18214059?v=4" width="100px;"/><br /><sub>Alcedo Nathaniel De Guzman Jr</sub>](https://twitter.com/natealcedo)<br />[πŸ’»](https://github.com/mattphillips/jest-extended/commits?author=natealcedo "Code") [πŸ“–](https://github.com/mattphillips/jest-extended/commits?author=natealcedo "Documentation") [πŸ’‘](#example-natealcedo "Examples") [⚠️](https://github.com/mattphillips/jest-extended/commits?author=natealcedo "Tests") | [<img src="https://avatars1.githubusercontent.com/u/65444?v=4" width="100px;"/><br /><sub>Pete Hodgson</sub>](http://thepete.net)<br />[πŸ’»](https://github.com/mattphillips/jest-extended/commits?author=moredip "Code") |
<!-- ALL-CONTRIBUTORS-LIST:END -->

@@ -885,0 +930,0 @@

@@ -294,2 +294,12 @@ /// <reference types="jest" />

/**
* Use `.toResolve` when checking if a promise resolves.
*/
toResolve(): R;
/**
* Use `.toReject` when checking if a promise rejects.
*/
toReject(): R;
/**
* Use `.toBeString` when checking if a value is a `String`.

@@ -341,2 +351,10 @@ */

toIncludeMultiple(substring: string[]): R;
/**
* Use `.toThrowWithMessage` when checking if a callback function throws an error of a given type with a given error message.
*
* @param {Function} type
* @param {String | RegExp} message
*/
toThrowWithMessage(type: Function, message: string | RegExp): R;
}

@@ -634,2 +652,12 @@

/**
* Use `.toResolve` when checking if a promise resolves.
*/
toResolve(): any;
/**
* Use `.toReject` when checking if a promise rejects.
*/
toReject(): any;
/**
* Use `.toBeString` when checking if a value is a `String`.

@@ -681,3 +709,11 @@ */

toIncludeMultiple(substring: string[]): any;
/**
* Use `.toThrowWithMessage` when checking if a callback function throws an error of a given type with a given error message.
*
* @param {Function} type
* @param {String | RegExp} message
*/
toThrowWithMessage(type: Function, message: string | RegExp): any;
}
}
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