Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 926a286

Browse files
test: replace Karma with Webdriver.IO (#17126)
* test: replace Karma with Webdriver.IO The current test framework for browser testing (Karma) is not maintained anymore and WebdriverIO provides a more modern stack that allows to test in different browser. This patch replaces these test frameworks. fixes: #17009 * update webdriverio deps * PR feedback * adjust tests * build eslint before running tests * make test file an esm file * revert more esm changes * make it work * remove return value * custom log dir for wdio tests * auto detect chromedriver * bump timeout, store logs * bump timeout again * update wdio deps * update wdio deps * set log level to trace * update wdio deps and unskip tests * no need to have this be an async test * update deps * make path spec file explicit * remove Chromedriver deps * removed wdio command
1 parent f591d2c commit 926a286

File tree

8 files changed

+416
-145
lines changed

8 files changed

+416
-145
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ jobs:
7575
- name: Install Packages
7676
run: npm install
7777
- name: Test
78-
run: node Makefile karma
78+
run: node Makefile wdio
7979
- name: Fuzz Test
8080
run: node Makefile fuzz
81+
- uses: actions/upload-artifact@v3
82+
if: failure()
83+
with:
84+
name: logs
85+
path: |
86+
wdio-logs/*.log

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
test.js
44
coverage/
55
build/
6+
logs
7+
wdio-logs
68
npm-debug.log
79
yarn-error.log
810
.pnpm-debug.log

Makefile.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -628,12 +628,10 @@ target.mocha = () => {
628628
}
629629
};
630630

631-
target.karma = () => {
631+
target.wdio = () => {
632632
echo("Running unit tests on browsers");
633-
634633
target.webpack("production");
635-
636-
const lastReturn = exec(`${getBinFile("karma")} start karma.conf.js`);
634+
const lastReturn = exec(`${getBinFile("wdio")} run wdio.conf.js`);
637635

638636
if (lastReturn.code !== 0) {
639637
exit(1);
@@ -643,7 +641,7 @@ target.karma = () => {
643641
target.test = function() {
644642
target.checkRuleFiles();
645643
target.mocha();
646-
target.karma();
644+
target.wdio();
647645
target.fuzz({ amount: 150, fuzzBrokenAutofixes: false });
648646
target.checkLicenses();
649647
};

karma.conf.js

Lines changed: 0 additions & 125 deletions
This file was deleted.

lib/config/rule-validator.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
// Requirements
1010
//-----------------------------------------------------------------------------
1111

12-
const ajv = require("../shared/ajv")();
12+
const ajvImport = require("../shared/ajv");
13+
const ajv = ajvImport();
1314
const {
1415
parseRuleId,
1516
getRuleFromConfig,

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@
101101
"devDependencies": {
102102
"@babel/core": "^7.4.3",
103103
"@babel/preset-env": "^7.4.3",
104+
"@wdio/browser-runner": "^8.14.6",
105+
"@wdio/cli": "^8.14.6",
106+
"@wdio/concise-reporter": "^8.14.0",
107+
"@wdio/globals": "^8.14.6",
108+
"@wdio/mocha-framework": "^8.14.0",
104109
"babel-loader": "^8.0.5",
105110
"c8": "^7.12.0",
106111
"chai": "^4.0.1",
@@ -124,11 +129,6 @@
124129
"glob": "^7.1.6",
125130
"got": "^11.8.3",
126131
"gray-matter": "^4.0.3",
127-
"karma": "^6.1.1",
128-
"karma-chrome-launcher": "^3.1.0",
129-
"karma-mocha": "^2.0.1",
130-
"karma-mocha-reporter": "^2.2.5",
131-
"karma-webpack": "^5.0.0",
132132
"lint-staged": "^11.0.0",
133133
"load-perf": "^0.2.0",
134134
"markdownlint": "^0.25.1",
@@ -148,12 +148,14 @@
148148
"pirates": "^4.0.5",
149149
"progress": "^2.0.3",
150150
"proxyquire": "^2.0.1",
151-
"puppeteer": "^13.7.0",
152151
"recast": "^0.20.4",
153152
"regenerator-runtime": "^0.13.2",
153+
"rollup-plugin-node-polyfills": "^0.2.1",
154154
"semver": "^7.5.3",
155155
"shelljs": "^0.8.2",
156156
"sinon": "^11.0.0",
157+
"vite-plugin-commonjs": "^0.8.2",
158+
"webdriverio": "^8.14.6",
157159
"webpack": "^5.23.0",
158160
"webpack-cli": "^4.5.0",
159161
"yorkie": "^2.0.0"

tests/lib/linter/linter.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// Requirements
1010
//------------------------------------------------------------------------------
1111

12-
const assert = require("chai").assert,
12+
const { assert } = require("chai"),
1313
sinon = require("sinon"),
1414
espree = require("espree"),
1515
esprima = require("esprima"),
@@ -7263,12 +7263,12 @@ var a = "test2";
72637263

72647264
it("should have file path passed to it", () => {
72657265
const code = "/* this is code */";
7266-
const parseSpy = sinon.spy(testParsers.stubParser, "parse");
7266+
const parseSpy = { parse: sinon.spy() };
72677267

7268-
linter.defineParser("stub-parser", testParsers.stubParser);
7268+
linter.defineParser("stub-parser", parseSpy);
72697269
linter.verify(code, { parser: "stub-parser" }, filename, true);
72707270

7271-
sinon.assert.calledWithMatch(parseSpy, "", { filePath: filename });
7271+
sinon.assert.calledWithMatch(parseSpy.parse, "", { filePath: filename });
72727272
});
72737273

72747274
it("should not report an error when JSX code contains a spread operator and JSX is enabled", () => {
@@ -8068,16 +8068,16 @@ describe("Linter with FlatConfigArray", () => {
80688068

80698069
it("should have file path passed to it", () => {
80708070
const code = "/* this is code */";
8071-
const parseSpy = sinon.spy(testParsers.stubParser, "parse");
8071+
const parseSpy = { parse: sinon.spy() };
80728072
const config = {
80738073
languageOptions: {
8074-
parser: testParsers.stubParser
8074+
parser: parseSpy
80758075
}
80768076
};
80778077

80788078
linter.verify(code, config, filename, true);
80798079

8080-
sinon.assert.calledWithMatch(parseSpy, "", { filePath: filename });
8080+
sinon.assert.calledWithMatch(parseSpy.parse, "", { filePath: filename });
80818081
});
80828082

80838083
it("should not report an error when JSX code contains a spread operator and JSX is enabled", () => {

0 commit comments

Comments
 (0)