diff --git a/karma.conf.js b/karma.conf.js index c1e73de..9e9100b 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,26 +1,25 @@ // eslint-disable-next-line @typescript-eslint/no-require-imports const webpackConfig = require("./webpack.config"); -module.exports = function(config) { - config.set({ +module.exports = function (config) { + config.set({ + basePath: "", + frameworks: ["mocha", "chai"], + files: ["test/unit/*.ts"], + exclude: [], + preprocessors: { + "test/unit/run-web-implementation.test.ts": ["webpack"], + }, + webpack: { + mode: "production", + node: webpackConfig.node, + module: webpackConfig.module, + resolve: webpackConfig.resolve, + }, + reporters: ["spec"], - basePath: "", - frameworks: ["mocha", "chai"], - files: ["test/unit/*.ts"], - exclude: [], - preprocessors: { - "test/**/*.ts": ["webpack"] - }, - webpack: { - mode: "production", - node: webpackConfig.node, - module: webpackConfig.module, - resolve: webpackConfig.resolve - }, - reporters: ["spec"], + browsers: ["ChromeHeadless"], - browsers: ["ChromeHeadless"], - - singleRun: true - }); -}; \ No newline at end of file + singleRun: true, + }); +}; diff --git a/test/unit/run-all-implementations.test.ts b/test/unit/run-all-implementations.test.ts index 854d6e3..ea90530 100644 --- a/test/unit/run-all-implementations.test.ts +++ b/test/unit/run-all-implementations.test.ts @@ -4,6 +4,7 @@ import {runPublicKeyTests} from "./publicKey.test"; import {runIndexTests} from "./index.test"; import {forEachImplementation} from "../switch"; +// Import test's bls lib lazily to prevent breaking test with Karma forEachImplementation(["blst", "herumi"], (bls) => { runPrivateKeyTests(bls); runPublicKeyTests(bls); diff --git a/test/unit/run-web-implementation.test.ts b/test/unit/run-web-implementation.test.ts index ea06044..31d18e0 100644 --- a/test/unit/run-web-implementation.test.ts +++ b/test/unit/run-web-implementation.test.ts @@ -1,12 +1,19 @@ +import herumi from "../../src/herumi"; import {runPrivateKeyTests} from "./privateKey.test"; import {runPublicKeyTests} from "./publicKey.test"; // import {runKeypairTests} from "./keypair.test"; import {runIndexTests} from "./index.test"; -import {forEachImplementation} from "../switch"; -forEachImplementation(["herumi"], (bls) => { - runPrivateKeyTests(bls); - runPublicKeyTests(bls); +// This file is intended to be compiled and run by Karma +// Do not import the node.bindings or it will break with: +// Error: BLST bindings loader should only run in a NodeJS context: process.platform +describe("herumi", () => { + before(async () => { + await herumi.initBLS(); + }); + + runPrivateKeyTests(herumi); + runPublicKeyTests(herumi); // runKeypairTests(bls); - runIndexTests(bls); + runIndexTests(herumi); });