Skip to content

Commit

Permalink
feature: supertape: remove dependency on deep-equal (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Mar 7, 2024
1 parent b6fb092 commit ebb9d46
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,17 +241,17 @@ Asserts that `result` and `expected` are not strictly equal. If `message` is pro

#### `t.deepEqual(result: any, expected: any, message?: string)`

Asserts that `result` and `expected` are loosely equal, with the same structure and nested values. If `message` is provided, it will be outputted as a description of the assertion.
Asserts that `result` and `expected` are equal, with the same structure and nested values. If `message` is provided, it will be outputted as a description of the assertion.

☝️ *Note: uses [node's deepEqual() algorithm][NodeDeepEqual] with strict comparisons (`===`) on leaf nodes*
☝️ *Note: uses [node's isDeepStrictEqual() algorithm][NodeDeepEqual] with strict comparisons (`===`) on leaf nodes*

#### `t.notDeepEqual(result: any, expected: any, message?: string)`

Asserts that `result` and `expected` not loosely equal, with different structure and/or nested values. If `message` is provided, it will be outputted as a description of the assertion.
Asserts that `result` and `expected` are not equal, with different structure and/or nested values. If `message` is provided, it will be outputted as a description of the assertion.

☝️ *Note: uses [node's deepEqual() algorithm][NodeDeepEqual] with strict comparisons (`===`) on leaf nodes*
☝️ *Note: uses [node's isDeepStrictEqual() algorithm][NodeDeepEqual] with strict comparisons (`===`) on leaf nodes*

[NodeDeepEqual]: https://github.com/substack/node-deep-equal
[NodeDeepEqual]: https://nodejs.org/dist/latest-v17.x/docs/api/util.html#utilisdeepstrictequalval1-val2

#### `t.ok(result: boolean | any, message?: string)`

Expand Down
6 changes: 3 additions & 3 deletions packages/supertape/lib/operators.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import deepEqualCheck from 'deep-equal';
import {isDeepStrictEqual} from 'node:util';
import diff from './diff.mjs';
import {
formatOutput,
Expand Down Expand Up @@ -119,7 +119,7 @@ const fail = (error, at) => ({
});

const deepEqual = (result, expected, message = 'should deep equal') => {
const is = deepEqualCheck(result, expected);
const is = isDeepStrictEqual(result, expected);
const output = is ? '' : diff(expected, result);

return {
Expand All @@ -132,7 +132,7 @@ const deepEqual = (result, expected, message = 'should deep equal') => {
};

const notDeepEqual = (result, expected, message = 'should not deep equal') => {
const is = !deepEqualCheck(result, expected);
const is = !isDeepStrictEqual(result, expected);
const output = is ? '' : diff(expected, result);

return {
Expand Down
1 change: 0 additions & 1 deletion packages/supertape/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"@supertape/formatter-time": "^1.0.0",
"@supertape/operator-stub": "^3.0.0",
"cli-progress": "^3.8.2",
"deep-equal": "^2.0.3",
"fullstore": "^3.0.0",
"glob": "^10.3.10",
"jest-diff": "^29.0.1",
Expand Down

0 comments on commit ebb9d46

Please sign in to comment.