Skip to content

Commit

Permalink
test: shim assert.strict for [email protected]
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmlnc committed Jan 7, 2025
1 parent 81c2d44 commit 210d0eb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"node": ">=8"
},
"scripts": {
"test": "mocha",
"test": "mocha -r ./test/mocha-initialization.js",
"benchmark": "node benchmark"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions test/braces.parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('braces.parse()', () => {
it('should return an AST', () => {
const ast = parse('a/{b,c}/d');
const brace = ast.nodes.find(node => node.type === 'brace');
assert(brace);
assert.ok(brace);
assert.equal(brace.nodes.length, 5);
});

Expand All @@ -30,7 +30,7 @@ describe('braces.parse()', () => {
const ast = parse('a/{a,b,[{c,d}]}/e');
const brace = ast.nodes[2];
const bracket = brace.nodes.find(node => node.value[0] === '[');
assert(bracket);
assert.ok(bracket);
assert.equal(bracket.value, '[{c,d}]');
});
});
Expand Down
17 changes: 17 additions & 0 deletions test/mocha-initialization.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @fileoverview
* This package works with [email protected] , which does not have support for `assert.strict`.
* This module is a shim to support these methods.
*
* @todo Remove this file when we drop support for [email protected].
*/
const assert = require('assert');

if (assert.strict === undefined) {
assert.strict = {
ok: assert.ok,
equal: assert.equal,
deepEqual: assert.deepEqual,
throws: assert.throws,
};
}

0 comments on commit 210d0eb

Please sign in to comment.