add web test runner

This commit is contained in:
Marin Petrunić 2020-02-06 09:52:33 +01:00
parent bf5d6658ee
commit 817ee2caf7
No known key found for this signature in database
GPG Key ID: 834D07135E110DA5
4 changed files with 2580 additions and 49 deletions

26
karma.conf.js Normal file
View File

@ -0,0 +1,26 @@
// eslint-disable-next-line @typescript-eslint/no-require-imports
const webpackConfig = require("./webpack.config");
module.exports = function(config) {
config.set({
basePath: "",
frameworks: ["mocha", "chai"],
files: ["test/**/*.test.ts"],
exclude: [],
preprocessors: {
"test/**/*.ts": ["webpack"]
},
webpack: {
mode: "production",
node: webpackConfig.node,
module: webpackConfig.module,
resolve: webpackConfig.resolve
},
reporters: ["spec"],
browsers: ["ChromeHeadless"],
singleRun: true
});
};

View File

@ -16,7 +16,9 @@
"check-types": "tsc --incremental --noEmit",
"lint": "eslint --ext .ts src/",
"pretest": "yarn check-types",
"test": "DEBUG=libp2p:noise mocha -r ./babel-register.js \"test/**/*.test.ts\""
"test": "yarn run test:node && yarn run test:web",
"test:node": "mocha -r ./babel-register.js \"test/**/*.test.ts\"",
"test:web": "karma start"
},
"babel": {
"presets": [
@ -51,9 +53,18 @@
"bn.js-typings": "^1.0.1",
"chai": "^4.2.0",
"eslint": "^6.6.0",
"karma": "^4.4.1",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.0",
"karma-cli": "^2.0.0",
"karma-mocha": "^1.3.0",
"karma-spec-reporter": "^0.0.32",
"karma-webpack": "^4.0.2",
"mocha": "^6.2.2",
"sinon": "^8.1.0",
"typescript": "^3.6.4"
"ts-loader": "^6.2.1",
"typescript": "^3.6.4",
"webpack": "^4.41.5"
},
"dependencies": {
"bcrypto": "^4.2.3",
@ -67,6 +78,6 @@
"it-pipe": "^1.1.0",
"libp2p-crypto": "^0.17.1",
"peer-id": "^0.13.5",
"protobufjs": "~6.8.8"
"protobufjs": "6.8.8"
}
}

19
webpack.config.js Normal file
View File

@ -0,0 +1,19 @@
module.exports = {
entry: "./src/index.ts",
mode: "production",
output: {
filename: "dist/bundle.js"
},
node: {
fs: "empty"
},
resolve: {
extensions: [".ts", ".js"],
},
module: {
rules: [
{test: /\.ts$/, use: {loader: "ts-loader", options: {transpileOnly: true}}}
],
},
};

2567
yarn.lock

File diff suppressed because it is too large Load Diff