From c182e03bac97d9e677fef8e21cf920dca39963a0 Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Thu, 9 May 2024 08:22:13 +0100 Subject: [PATCH] chore: upgrade check-error --- lib/chai/utils/index.js | 3 +- package-lock.json | 8 ++--- package.json | 2 +- test/virtual-machines.js | 65 +++++++++++++++++++++------------------- 4 files changed, 41 insertions(+), 37 deletions(-) diff --git a/lib/chai/utils/index.js b/lib/chai/utils/index.js index 212fc168..80306f79 100644 --- a/lib/chai/utils/index.js +++ b/lib/chai/utils/index.js @@ -98,8 +98,9 @@ export {getOperator} from './getOperator.js'; /** * Determines if an object is a `RegExp` * This is used since `instanceof` will not work in virtual contexts + * * @param {*} obj Object to test - * @return {boolean} + * @returns {boolean} */ export function isRegExp(obj) { return Object.prototype.toString.call(obj) === '[object RegExp]'; diff --git a/package-lock.json b/package-lock.json index 4ce438d5..4848b60c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "assertion-error": "^2.0.1", - "check-error": "^2.0.0", + "check-error": "^2.1.1", "deep-eql": "^5.0.1", "loupe": "^3.1.0", "pathval": "^2.0.0" @@ -2027,9 +2027,9 @@ } }, "node_modules/check-error": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.0.0.tgz", - "integrity": "sha512-tjLAOBHKVxtPoHe/SA7kNOMvhCRdCJ3vETdeY0RuAc9popf+hyaSV6ZEg9hr4cpWF7jmo/JSWEnLDrnijS9Tog==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.1.tgz", + "integrity": "sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==", "engines": { "node": ">= 16" } diff --git a/package.json b/package.json index f2f9aad1..a2cb11ff 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ }, "dependencies": { "assertion-error": "^2.0.1", - "check-error": "^2.0.0", + "check-error": "^2.1.1", "deep-eql": "^5.0.1", "loupe": "^3.1.0", "pathval": "^2.0.0" diff --git a/test/virtual-machines.js b/test/virtual-machines.js index 92ac1978..da5ec416 100644 --- a/test/virtual-machines.js +++ b/test/virtual-machines.js @@ -1,31 +1,34 @@ -import vm from 'node:vm'; -import * as chai from '../index.js'; - -const {assert} = chai; -const vmContext = {assert}; -vm.createContext(vmContext); - -function runCodeInVm(code) { - vm.runInContext(code, vmContext); -} - -describe('node virtual machines', function () { - it('throws', function() { - const shouldNotThrow = [ - `assert.throws(function() { throw ''; }, /^$/);`, - `assert.throws(function() { throw new Error('bleepbloop'); });`, - `assert.throws(function() { throw new Error(''); });`, - // TODO (43081j): enable this test once check-error supports - // cross-vm `Error` objects - //`assert.throws(function() { throw new Error('swoosh'); }, /swoosh/);` - ]; - - for (const code of shouldNotThrow) { - assert.doesNotThrow( - () => { - runCodeInVm(code); - } - ); - } - }); -}); +import vm from 'node:vm'; +import * as chai from '../index.js'; + +const {assert} = chai; +const vmContext = {assert}; +vm.createContext(vmContext); + +/** + * Run the code in a virtual context + * + * @param {string} code Code to run + */ +function runCodeInVm(code) { + vm.runInContext(code, vmContext); +} + +describe('node virtual machines', function () { + it('throws', function() { + const shouldNotThrow = [ + `assert.throws(function() { throw ''; }, /^$/);`, + `assert.throws(function() { throw new Error('bleepbloop'); });`, + `assert.throws(function() { throw new Error(''); });`, + `assert.throws(function() { throw new Error('swoosh'); }, /swoosh/);` + ]; + + for (const code of shouldNotThrow) { + assert.doesNotThrow( + () => { + runCodeInVm(code); + } + ); + } + }); +});