From 210d0eb9062a4e7493329a22bace403b9e090aec Mon Sep 17 00:00:00 2001 From: mrmlnc Date: Tue, 7 Jan 2025 16:30:15 +0300 Subject: [PATCH] test: shim `assert.strict` for node@8.3.0 --- package.json | 2 +- test/braces.parse.js | 4 ++-- test/mocha-initialization.js | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 test/mocha-initialization.js diff --git a/package.json b/package.json index c3c056e..3b61624 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "node": ">=8" }, "scripts": { - "test": "mocha", + "test": "mocha -r ./test/mocha-initialization.js", "benchmark": "node benchmark" }, "dependencies": { diff --git a/test/braces.parse.js b/test/braces.parse.js index 9158316..d5a7404 100644 --- a/test/braces.parse.js +++ b/test/braces.parse.js @@ -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); }); @@ -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}]'); }); }); diff --git a/test/mocha-initialization.js b/test/mocha-initialization.js new file mode 100644 index 0000000..fb19a21 --- /dev/null +++ b/test/mocha-initialization.js @@ -0,0 +1,17 @@ +/** + * @fileoverview + * This package works with node@8.3.0 , 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 node@8.3.0. + */ +const assert = require('assert'); + +if (assert.strict === undefined) { + assert.strict = { + ok: assert.ok, + equal: assert.equal, + deepEqual: assert.deepEqual, + throws: assert.throws, + }; +}