Run only web implementation in Karma

This commit is contained in:
dapplion 2020-11-20 19:08:53 +00:00
parent 4424bed87d
commit 70ccbfbe5b
3 changed files with 33 additions and 26 deletions

View File

@ -3,24 +3,23 @@ const webpackConfig = require("./webpack.config");
module.exports = function (config) { module.exports = function (config) {
config.set({ config.set({
basePath: "", basePath: "",
frameworks: ["mocha", "chai"], frameworks: ["mocha", "chai"],
files: ["test/unit/*.ts"], files: ["test/unit/*.ts"],
exclude: [], exclude: [],
preprocessors: { preprocessors: {
"test/**/*.ts": ["webpack"] "test/unit/run-web-implementation.test.ts": ["webpack"],
}, },
webpack: { webpack: {
mode: "production", mode: "production",
node: webpackConfig.node, node: webpackConfig.node,
module: webpackConfig.module, module: webpackConfig.module,
resolve: webpackConfig.resolve resolve: webpackConfig.resolve,
}, },
reporters: ["spec"], reporters: ["spec"],
browsers: ["ChromeHeadless"], browsers: ["ChromeHeadless"],
singleRun: true singleRun: true,
}); });
}; };

View File

@ -4,6 +4,7 @@ import {runPublicKeyTests} from "./publicKey.test";
import {runIndexTests} from "./index.test"; import {runIndexTests} from "./index.test";
import {forEachImplementation} from "../switch"; import {forEachImplementation} from "../switch";
// Import test's bls lib lazily to prevent breaking test with Karma
forEachImplementation(["blst", "herumi"], (bls) => { forEachImplementation(["blst", "herumi"], (bls) => {
runPrivateKeyTests(bls); runPrivateKeyTests(bls);
runPublicKeyTests(bls); runPublicKeyTests(bls);

View File

@ -1,12 +1,19 @@
import herumi from "../../src/herumi";
import {runPrivateKeyTests} from "./privateKey.test"; import {runPrivateKeyTests} from "./privateKey.test";
import {runPublicKeyTests} from "./publicKey.test"; import {runPublicKeyTests} from "./publicKey.test";
// import {runKeypairTests} from "./keypair.test"; // import {runKeypairTests} from "./keypair.test";
import {runIndexTests} from "./index.test"; import {runIndexTests} from "./index.test";
import {forEachImplementation} from "../switch";
forEachImplementation(["herumi"], (bls) => { // This file is intended to be compiled and run by Karma
runPrivateKeyTests(bls); // Do not import the node.bindings or it will break with:
runPublicKeyTests(bls); // Error: BLST bindings loader should only run in a NodeJS context: process.platform
// runKeypairTests(bls); describe("herumi", () => {
runIndexTests(bls); before(async () => {
await herumi.initBLS();
});
runPrivateKeyTests(herumi);
runPublicKeyTests(herumi);
// runKeypairTests(bls);
runIndexTests(herumi);
}); });