Slight adjustment to tests (#402)
* Slight adjustment to tests * beforeAll adjustment * Adjust test forEach * Test import map removal * Adjust * Remove input import_map template
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"imports": {
|
||||
"crypto": "https://deno.land/std/node/crypto.ts",
|
||||
"@polkadot/util": "https://deno.land/x/polkadot/util/mod.ts"
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -41,7 +41,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.18.6",
|
||||
"@polkadot/dev": "^0.67.73",
|
||||
"@polkadot/dev": "^0.67.79",
|
||||
"fflate": "^0.7.3",
|
||||
"override-require": "^1.1.1"
|
||||
},
|
||||
|
||||
@@ -27,7 +27,7 @@ async function beforeAll (name, wasm) {
|
||||
|
||||
console.log(`*** waitReady()=${result} for ${wasm.bridge.type}`);
|
||||
|
||||
assert(name.toLowerCase() === wasm.bridge.type, `Incorrect environment laucnhed, expected ${name.toLowerCase()}, found ${wasm.bridge.type}`);
|
||||
assert(name.toLowerCase() === wasm.bridge.type, `Incorrect environment launched, expected ${name.toLowerCase()}, found ${wasm.bridge.type}`);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -36,26 +36,28 @@ function runAll (name, wasm) {
|
||||
const failed = [];
|
||||
let count = 0;
|
||||
|
||||
Object.keys(tests).forEach((name) => {
|
||||
const timerId = `\t${name}`;
|
||||
Object
|
||||
.entries(tests)
|
||||
.forEach(([name, test]) => {
|
||||
const timerId = `\t${name}`;
|
||||
|
||||
count++;
|
||||
count++;
|
||||
|
||||
try {
|
||||
console.time(timerId);
|
||||
console.log();
|
||||
console.log(timerId);
|
||||
try {
|
||||
console.time(timerId);
|
||||
console.log();
|
||||
console.log(timerId);
|
||||
|
||||
tests[name](wasm);
|
||||
test(wasm);
|
||||
|
||||
console.timeEnd(timerId);
|
||||
} catch (error) {
|
||||
console.error();
|
||||
console.error(error);
|
||||
console.timeEnd(timerId);
|
||||
} catch (error) {
|
||||
console.error();
|
||||
console.error(error);
|
||||
|
||||
failed.push(name);
|
||||
}
|
||||
});
|
||||
failed.push(name);
|
||||
}
|
||||
});
|
||||
|
||||
if (failed.length) {
|
||||
throw new Error(`\n*** ${name}: FAILED: ${failed.length} of ${count}: ${failed.join(', ')}`);
|
||||
|
||||
@@ -6,14 +6,15 @@ import { createRequire } from 'https://deno.land/std@0.107.0/node/module.ts';
|
||||
import * as wasm from '../build-deno/mod.ts';
|
||||
|
||||
declare const globalThis: Record<string, unknown>;
|
||||
declare const require: (name: string) => any;
|
||||
|
||||
globalThis.require = createRequire(import.meta.url);
|
||||
// ensure we set require on globalThis, it is used is all/*.js
|
||||
const require = globalThis.require = createRequire(import.meta.url);
|
||||
const { beforeAll, tests } = require('./all/index.js');
|
||||
|
||||
const exp = require('./all/index.js');
|
||||
await beforeAll('wasm', wasm);
|
||||
|
||||
await exp.beforeAll('wasm', wasm);
|
||||
|
||||
Object.keys(exp.tests).forEach((name) => {
|
||||
Deno.test(name, () => exp.tests[name](wasm));
|
||||
});
|
||||
Object
|
||||
.entries<(wasm: unknown) => void>(tests)
|
||||
.forEach(([name, test]) => {
|
||||
Deno.test(name, () => test(wasm));
|
||||
});
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
import * as wasm from '../build';
|
||||
import { beforeAll as beforeAllFn, tests } from './all/index.js';
|
||||
|
||||
globalThis.wasm = wasm;
|
||||
|
||||
describe('wasm-crypto', () => {
|
||||
beforeAll(async () => {
|
||||
await beforeAllFn('wasm', wasm);
|
||||
|
||||
Reference in New Issue
Block a user