Test in new world (#3822)

This commit is contained in:
Manish Jethani 2021-08-15 18:11:30 +05:30 committed by GitHub
parent bd8cb8d50f
commit 0a11999459
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 10 deletions

View File

@ -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",

View File

@ -31,6 +31,7 @@
},
"devDependencies": {
"eslint": "^7.32.0",
"esm-world": "github:mjethani/esm-world#0e5a77a5c0cb22de28616bba9ed7247dee218fb3",
"mocha": "^9.0.3"
}
}

View File

@ -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() {

View File

@ -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 () => {