diff --git a/platform/nodejs/package-lock.json b/platform/nodejs/package-lock.json index d15ce11d6..2b1eeb32a 100644 --- a/platform/nodejs/package-lock.json +++ b/platform/nodejs/package-lock.json @@ -462,6 +462,11 @@ "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", "dev": true }, + "esm-world": { + "version": "github:mjethani/esm-world#0e5a77a5c0cb22de28616bba9ed7247dee218fb3", + "from": "github:mjethani/esm-world#0e5a77a5c0cb22de28616bba9ed7247dee218fb3", + "dev": true + }, "espree": { "version": "7.3.1", "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.1.tgz", diff --git a/platform/nodejs/package.json b/platform/nodejs/package.json index a933c4efe..4f9472876 100644 --- a/platform/nodejs/package.json +++ b/platform/nodejs/package.json @@ -31,6 +31,7 @@ }, "devDependencies": { "eslint": "^7.32.0", + "esm-world": "github:mjethani/esm-world#0e5a77a5c0cb22de28616bba9ed7247dee218fb3", "mocha": "^9.0.3" } } diff --git a/platform/nodejs/test.js b/platform/nodejs/test.js index e4a0b8331..15e3db0c4 100644 --- a/platform/nodejs/test.js +++ b/platform/nodejs/test.js @@ -134,7 +134,7 @@ async function doHNTrie() { } async function spawnMocha() { - await promisify(spawn)('mocha', [ 'tests' ], { stdio: [ 'inherit', 'inherit', 'inherit' ] }); + await promisify(spawn)('mocha', [ '--experimental-vm-modules', '--no-warnings', 'tests' ], { stdio: [ 'inherit', 'inherit', 'inherit' ] }); } async function main() { diff --git a/platform/nodejs/tests/snfe.js b/platform/nodejs/tests/snfe.js index fa3011124..a4b29e2cc 100644 --- a/platform/nodejs/tests/snfe.js +++ b/platform/nodejs/tests/snfe.js @@ -24,22 +24,28 @@ /******************************************************************************/ import { strict as assert } from 'assert'; +import process from 'process'; -import { - StaticNetFilteringEngine, -} from '../index.js'; +import { createWorld } from 'esm-world'; + +process.on('warning', warning => { + // Ignore warnings about experimental features like + // --experimental-vm-modules + if ( warning.name !== 'ExperimentalWarning' ) { + console.warn(warning.stack); + } +}); let engine = null; describe('SNFE', () => { - before(async () => { - engine = await StaticNetFilteringEngine.create(); - }); - describe('Filter loading', () => { beforeEach(async () => { - // This is in lieu of a constructor for a non-singleton. - await engine.useLists([]); + const globals = { URL, setTimeout, clearTimeout }; + + const { StaticNetFilteringEngine } = await createWorld('./index.js', { globals }); + + engine = await StaticNetFilteringEngine.create(); }); it('should not reject on no lists', async () => {