Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/center-key/assert-deep-strict-equal
⚖️ Asynchronous assert fails in Mocha you can see and don't timeout (with TypeScript declarations)
https://github.com/center-key/assert-deep-strict-equal
assert deep done equal mocha strict timeout
Last synced: 13 days ago
JSON representation
⚖️ Asynchronous assert fails in Mocha you can see and don't timeout (with TypeScript declarations)
- Host: GitHub
- URL: https://github.com/center-key/assert-deep-strict-equal
- Owner: center-key
- License: mit
- Created: 2021-06-23T09:33:35.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-14T16:36:21.000Z (4 months ago)
- Last Synced: 2024-11-29T17:54:41.540Z (27 days ago)
- Topics: assert, deep, done, equal, mocha, strict, timeout
- Language: TypeScript
- Homepage:
- Size: 491 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# assert-deep-strict-equal
_Asynchronous assert fails in Mocha you can see and don't timeout_
[![License:MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/center-key/assert-deep-strict-equal/blob/main/LICENSE.txt)
[![npm](https://img.shields.io/npm/v/assert-deep-strict-equal.svg)](https://www.npmjs.com/package/assert-deep-strict-equal)
[![Build](https://github.com/center-key/assert-deep-strict-equal/actions/workflows/run-spec-on-push.yaml/badge.svg)](https://github.com/center-key/assert-deep-strict-equal/actions/workflows/run-spec-on-push.yaml)## A) Setup
Install package for node:
```shell
$ npm install --save-dev assert-deep-strict-equal
```
Import into your Mocha spec file:
```javascript
import { assertDeepStrictEqual } from 'assert-deep-strict-equal';
```## B) Usage
```javascript
const actual = { ingredient: 'sugar', units: 'grams', amount: 100 };
const expected = { ingredient: 'sugar', units: 'grams', amount: 100 };
assertDeepStrictEqual(actual, expected, done);
```
The third parameter for the `done` callback is optional:
```javascript
assertDeepStrictEqual(actual, expected); //synchronous test case
```## C) Example
```javascript
describe('Star Wars API result for spaceship #3', () => {it('is a Star Destroyer', (done) => {
const url = 'https://swapi.py4e.com/api/starships/3/';
const handleData = (data) => {
const actual = {
name: data.name,
model: data.model,
manufacturer: data.manufacturer,
};
const expected = {
name: 'Star Destroyer',
model: 'Imperial I-class Star Destroyer',
manufacturer: 'Kuat Drive Yards',
};
assertDeepStrictEqual(actual, expected, done);
};
fetchJson.get(url, { format: 'json' }).then(handleData);
});});
```
Commands to run the above **Star Destroyer** example and others in [examples.spec.js](examples.spec.js):
```shell
$ cd assert-deep-strict-equal
$ npm install
$ npm run examples
```
Note that the assertion failure does _not_ cause a timeout and the test case error is easy to see and interpret.
The value of the `name` field is `"BOGUS!"` (red), but it was expected to be `"payapa-berry"` (green).
---
[MIT License](LICENSE.txt)