js-noise/karma.conf.cjs

71 lines
1.7 KiB
JavaScript
Raw Normal View History

2022-11-13 13:39:26 +00:00
process.env.CHROME_BIN = require("puppeteer").executablePath();
const os = require("os");
const path = require("path");
const ResolveTypeScriptPlugin = require("resolve-typescript-plugin");
const output = {
2022-11-15 21:56:25 +00:00
path: path.join(os.tmpdir(), "_karma_webpack_") + Math.floor(Math.random() * 1000000),
2022-11-13 13:39:26 +00:00
};
module.exports = function (config) {
config.set({
2023-01-31 23:34:05 +00:00
frameworks: ["webpack", "mocha"],
2022-11-13 13:39:26 +00:00
preprocessors: {
2023-01-31 23:27:23 +00:00
"**/*.ts": ["webpack"],
2022-11-13 13:39:26 +00:00
},
files: [
"src/**/*.spec.ts",
"src/**/*.ts",
{
pattern: `${output.path}/**/*`,
watched: false,
included: false,
served: true,
},
],
envPreprocessor: ["CI"],
reporters: ["progress"],
browsers: ["ChromeHeadless"],
singleRun: true,
client: {
mocha: {
timeout: 6000, // Default is 2s
},
},
webpack: {
mode: "production",
2023-02-02 00:08:09 +00:00
optimization: {
// minification is disabled due to an issue with missing variable
// https://github.com/waku-org/js-noise/pull/18#discussion_r1100712310
2023-02-02 00:08:09 +00:00
minimize: false,
},
2023-02-01 23:03:26 +00:00
resolve: {
// Add `.ts` and `.tsx` as a resolvable extension.
extensions: [".ts", ".tsx", ".js"],
plugins: [new ResolveTypeScriptPlugin()],
},
2022-11-13 13:39:26 +00:00
module: {
rules: [
{
test: /\.wasm$/,
type: "asset/resource",
},
{
test: /\.(js|tsx?)$/,
loader: "ts-loader",
2023-02-01 00:43:40 +00:00
exclude: /node_modules|\.d\.ts$/,
2022-11-13 13:39:26 +00:00
options: { configFile: "tsconfig.karma.json" },
},
2023-02-01 00:02:03 +00:00
{
test: /\.d\.ts$/,
loader: "ignore-loader",
},
2022-11-13 13:39:26 +00:00
],
},
output,
},
});
};