Replace karma-env-preproc with webpack

This commit is contained in:
Franck Royer 2022-05-23 14:40:37 +10:00
parent cb10ca16d1
commit 4352cb923d
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
6 changed files with 11 additions and 40 deletions

View File

@ -1,12 +1,13 @@
process.env.CHROME_BIN = require("puppeteer").executablePath();
const webpackConfig = require("./webpack.config.cjs");
const webpack = require("webpack");
module.exports = function (config) {
config.set({
frameworks: ["webpack", "mocha"],
files: ["src/lib/**/!(node).spec.ts"],
preprocessors: {
"src/lib/**/!(node).spec.ts": ["env", "webpack"],
"src/lib/**/!(node).spec.ts": ["webpack"],
},
envPreprocessor: ["CI"],
reporters: ["progress"],
@ -20,7 +21,12 @@ module.exports = function (config) {
webpack: {
mode: "production",
module: webpackConfig.module,
plugins: webpackConfig.plugins,
plugins: [
new webpack.DefinePlugin({
"process.env.CI": process.env.CI || false,
}),
...webpackConfig.plugins,
],
resolve: webpackConfig.resolve,
stats: { warnings: false },
},

13
package-lock.json generated
View File

@ -67,7 +67,6 @@
"jsdom-global": "^3.0.2",
"karma": "^6.3.12",
"karma-chrome-launcher": "^3.1.0",
"karma-env-preprocessor": "^0.1.1",
"karma-mocha": "^2.0.1",
"karma-webpack": "^5.0.0",
"lint-staged": "^12.3.4",
@ -6883,12 +6882,6 @@
"which": "bin/which"
}
},
"node_modules/karma-env-preprocessor": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/karma-env-preprocessor/-/karma-env-preprocessor-0.1.1.tgz",
"integrity": "sha1-u+jIfVnADtt2BwvTwxtLOdXcfhU=",
"dev": true
},
"node_modules/karma-mocha": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/karma-mocha/-/karma-mocha-2.0.1.tgz",
@ -17155,12 +17148,6 @@
}
}
},
"karma-env-preprocessor": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/karma-env-preprocessor/-/karma-env-preprocessor-0.1.1.tgz",
"integrity": "sha1-u+jIfVnADtt2BwvTwxtLOdXcfhU=",
"dev": true
},
"karma-mocha": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/karma-mocha/-/karma-mocha-2.0.1.tgz",

View File

@ -123,7 +123,6 @@
"jsdom-global": "^3.0.2",
"karma": "^6.3.12",
"karma-chrome-launcher": "^3.1.0",
"karma-env-preprocessor": "^0.1.1",
"karma-mocha": "^2.0.1",
"karma-webpack": "^5.0.0",
"lint-staged": "^12.3.4",

View File

@ -3,13 +3,6 @@ import { expect } from "chai";
import { DnsClient, DnsNodeDiscovery } from "./dns";
import testData from "./testdata.json";
declare global {
interface Window {
__env__?: any;
}
}
declare let window: Window | undefined;
const mockData = testData.dns;
const host = "nodes.example.org";
@ -273,7 +266,7 @@ describe("DNS Node Discovery [live data]", function () {
const maxQuantity = 3;
before(function () {
if (process.env.CI || window?.__env__?.CI) {
if (process.env.CI) {
this.skip();
}
});

View File

@ -3,13 +3,6 @@ import { expect } from "chai";
import { fleets } from "./predefined";
import { getPseudoRandomSubset } from "./random_subset";
declare global {
interface Window {
__env__?: any;
}
}
declare let window: Window | undefined;
describe("Discovery", () => {
it("returns all values when wanted number matches available values", function () {
const values = ["a", "b", "c"];
@ -44,7 +37,7 @@ describe("Discovery", () => {
describe("Discovery [live data]", function () {
before(function () {
if (process.env.CI || window?.__env__?.CI) {
if (process.env.CI) {
this.skip();
}
});

View File

@ -3,13 +3,6 @@ import PeerId from "peer-id";
import { Waku } from "./waku";
declare global {
interface Window {
__env__?: any;
}
}
declare let window: Window | undefined;
describe("Waku Dial", function () {
describe("Bootstrap [live data]", function () {
let waku: Waku;
@ -19,7 +12,7 @@ describe("Waku Dial", function () {
});
before(function () {
if (process.env.CI || window?.__env__?.CI) {
if (process.env.CI) {
this.skip();
}
});