From 88e95cba630df4eab0598e8df0202555b96eb9a4 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Mon, 5 Aug 2024 12:32:20 +0200 Subject: [PATCH] TEMP: Switch to web-test-runner Karma is deprecated, so switch to something that is still maintained. --- karma.conf.js | 92 ------------------------------------ package.json | 15 ++---- tests/assertions.js | 4 +- tests/test.base64.js | 2 +- tests/test.browser.js | 2 +- tests/test.copyrect.js | 2 +- tests/test.deflator.js | 2 +- tests/test.display.js | 4 +- tests/test.gesturehandler.js | 4 +- tests/test.helper.js | 2 +- tests/test.hextile.js | 2 +- tests/test.inflator.js | 2 +- tests/test.int.js | 2 +- tests/test.jpeg.js | 2 +- tests/test.keyboard.js | 4 +- tests/test.localization.js | 4 +- tests/test.raw.js | 2 +- tests/test.rfb.js | 4 +- tests/test.rre.js | 2 +- tests/test.tight.js | 2 +- tests/test.tightpng.js | 2 +- tests/test.util.js | 4 +- tests/test.websock.js | 4 +- tests/test.webutil.js | 4 +- tests/test.zrle.js | 2 +- web-test-runner.config.mjs | 13 +++++ 26 files changed, 48 insertions(+), 136 deletions(-) delete mode 100644 karma.conf.js create mode 100644 web-test-runner.config.mjs diff --git a/karma.conf.js b/karma.conf.js deleted file mode 100644 index a019887f..00000000 --- a/karma.conf.js +++ /dev/null @@ -1,92 +0,0 @@ -// Karma configuration - -// The Safari launcher is broken, so construct our own -function SafariBrowser(id, baseBrowserDecorator, args) { - baseBrowserDecorator(this); - - this._start = function(url) { - this._execCommand('/usr/bin/open', ['-W', '-n', '-a', 'Safari', url]); - } -} - -SafariBrowser.prototype = { - name: 'Safari' -} - -module.exports = (config) => { - let browsers = []; - - if (process.env.TEST_BROWSER_NAME) { - browsers = process.env.TEST_BROWSER_NAME.split(','); - } - - const my_conf = { - - // base path that will be used to resolve all patterns (eg. files, exclude) - basePath: '', - - // frameworks to use - // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ['mocha'], - - // list of files / patterns to load in the browser - files: [ - // node modules - { pattern: 'node_modules/chai/**', included: false }, - { pattern: 'node_modules/sinon/**', included: false }, - { pattern: 'node_modules/sinon-chai/**', included: false }, - // modules to test - { pattern: 'app/localization.js', included: false, type: 'module' }, - { pattern: 'app/webutil.js', included: false, type: 'module' }, - { pattern: 'core/**/*.js', included: false, type: 'module' }, - { pattern: 'vendor/pako/**/*.js', included: false, type: 'module' }, - // tests - { pattern: 'tests/test.*.js', type: 'module' }, - // test support files - { pattern: 'tests/fake.*.js', included: false, type: 'module' }, - { pattern: 'tests/assertions.js', included: false, type: 'module' }, - ], - - client: { - mocha: { - // replace Karma debug page with mocha display - 'reporter': 'html', - 'ui': 'bdd' - } - }, - - // list of files to exclude - exclude: [ - ], - - plugins: [ - 'karma-*', - '@chiragrupani/karma-chromium-edge-launcher', - { 'launcher:Safari': [ 'type', SafariBrowser ] }, - ], - - // start these browsers - // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: browsers, - - // test results reporter to use - // possible values: 'dots', 'progress' - // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ['mocha'], - - - // level of logging - // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG - logLevel: config.LOG_INFO, - - - // enable / disable watching file and executing tests whenever any file changes - autoWatch: false, - - // Continuous Integration mode - // if true, Karma captures browsers, runs the tests and exits - singleRun: true, - }; - - config.set(my_conf); -}; diff --git a/package.json b/package.json index e28850a8..1558d838 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ ], "scripts": { "lint": "eslint app core po/po2js po/xgettext-html tests utils", - "test": "karma start karma.conf.js", + "test": "web-test-runner", "prepublish": "node ./utils/convert.js --clean" }, "repository": { @@ -46,22 +46,13 @@ "fs-extra": "latest", "globals": "latest", "jsdom": "latest", - "karma": "latest", - "karma-mocha": "latest", - "karma-chrome-launcher": "latest", - "@chiragrupani/karma-chromium-edge-launcher": "latest", - "karma-firefox-launcher": "latest", - "karma-ie-launcher": "latest", - "karma-mocha-reporter": "latest", - "karma-safari-launcher": "latest", - "karma-script-launcher": "latest", "mocha": "latest", "node-getopt": "latest", "po2json": "latest", "sinon": "latest", - "sinon-chai": "latest" + "sinon-chai": "latest", + "@web/test-runner": "latest" }, - "dependencies": {}, "keywords": [ "vnc", "rfb", diff --git a/tests/assertions.js b/tests/assertions.js index ea0003b6..34ab038f 100644 --- a/tests/assertions.js +++ b/tests/assertions.js @@ -1,5 +1,5 @@ -import * as chai from '../node_modules/chai/chai.js'; -import sinonChai from '../node_modules/sinon-chai/lib/sinon-chai.js'; +import * as chai from 'chai'; +import sinonChai from 'sinon-chai'; chai.use(sinonChai); diff --git a/tests/test.base64.js b/tests/test.base64.js index 120608e3..b29a80d8 100644 --- a/tests/test.base64.js +++ b/tests/test.base64.js @@ -1,4 +1,4 @@ -import { expect } from '../node_modules/chai/chai.js'; +import { expect } from 'chai'; import Base64 from '../core/base64.js'; diff --git a/tests/test.browser.js b/tests/test.browser.js index fa82e7bc..936db2a1 100644 --- a/tests/test.browser.js +++ b/tests/test.browser.js @@ -1,4 +1,4 @@ -import { expect } from '../node_modules/chai/chai.js'; +import { expect } from 'chai'; import { isMac, isWindows, isIOS, isAndroid, isChromeOS, isSafari, isFirefox, isChrome, isChromium, isOpera, isEdge, diff --git a/tests/test.copyrect.js b/tests/test.copyrect.js index ad9f8b31..81e425c6 100644 --- a/tests/test.copyrect.js +++ b/tests/test.copyrect.js @@ -1,5 +1,5 @@ import './assertions.js'; -import { expect } from '../node_modules/chai/chai.js'; +import { expect } from 'chai'; import Websock from '../core/websock.js'; import Display from '../core/display.js'; diff --git a/tests/test.deflator.js b/tests/test.deflator.js index 76c4d8f1..18170941 100644 --- a/tests/test.deflator.js +++ b/tests/test.deflator.js @@ -1,5 +1,5 @@ import './assertions.js'; -import { expect } from '../node_modules/chai/chai.js'; +import { expect } from 'chai'; import { inflateInit, inflate } from "../vendor/pako/lib/zlib/inflate.js"; import ZStream from "../vendor/pako/lib/zlib/zstream.js"; diff --git a/tests/test.display.js b/tests/test.display.js index 131e76d1..37990e8e 100644 --- a/tests/test.display.js +++ b/tests/test.display.js @@ -1,6 +1,6 @@ import './assertions.js'; -import { expect } from '../node_modules/chai/chai.js'; -import sinon from '../node_modules/sinon/pkg/sinon-esm.js'; +import { expect } from 'chai'; +import sinon from 'sinon'; import Base64 from '../core/base64.js'; import Display from '../core/display.js'; diff --git a/tests/test.gesturehandler.js b/tests/test.gesturehandler.js index 880cdd14..798eab19 100644 --- a/tests/test.gesturehandler.js +++ b/tests/test.gesturehandler.js @@ -1,6 +1,6 @@ import './assertions.js'; -import { expect } from '../node_modules/chai/chai.js'; -import sinon from '../node_modules/sinon/pkg/sinon-esm.js'; +import { expect } from 'chai'; +import sinon from 'sinon'; import EventTargetMixin from '../core/util/eventtarget.js'; diff --git a/tests/test.helper.js b/tests/test.helper.js index 04428dd1..17fc568e 100644 --- a/tests/test.helper.js +++ b/tests/test.helper.js @@ -1,4 +1,4 @@ -import { expect } from '../node_modules/chai/chai.js'; +import { expect } from 'chai'; import keysyms from '../core/input/keysymdef.js'; import * as KeyboardUtil from "../core/input/util.js"; diff --git a/tests/test.hextile.js b/tests/test.hextile.js index 5a59e97b..70607bef 100644 --- a/tests/test.hextile.js +++ b/tests/test.hextile.js @@ -1,5 +1,5 @@ import './assertions.js'; -import { expect } from '../node_modules/chai/chai.js'; +import { expect } from 'chai'; import Websock from '../core/websock.js'; import Display from '../core/display.js'; diff --git a/tests/test.inflator.js b/tests/test.inflator.js index b1ebb722..8553beba 100644 --- a/tests/test.inflator.js +++ b/tests/test.inflator.js @@ -1,5 +1,5 @@ import './assertions.js'; -import { expect } from '../node_modules/chai/chai.js'; +import { expect } from 'chai'; import { deflateInit, deflate, Z_FULL_FLUSH } from "../vendor/pako/lib/zlib/deflate.js"; import ZStream from "../vendor/pako/lib/zlib/zstream.js"; diff --git a/tests/test.int.js b/tests/test.int.js index 641d9db6..739dde89 100644 --- a/tests/test.int.js +++ b/tests/test.int.js @@ -1,4 +1,4 @@ -import { expect } from '../node_modules/chai/chai.js'; +import { expect } from 'chai'; import { toUnsigned32bit, toSigned32bit } from '../core/util/int.js'; diff --git a/tests/test.jpeg.js b/tests/test.jpeg.js index b50f22a5..692de448 100644 --- a/tests/test.jpeg.js +++ b/tests/test.jpeg.js @@ -1,5 +1,5 @@ import './assertions.js'; -import { expect } from '../node_modules/chai/chai.js'; +import { expect } from 'chai'; import Websock from '../core/websock.js'; import Display from '../core/display.js'; diff --git a/tests/test.keyboard.js b/tests/test.keyboard.js index d7c4de8a..14d0ff42 100644 --- a/tests/test.keyboard.js +++ b/tests/test.keyboard.js @@ -1,6 +1,6 @@ import './assertions.js'; -import { expect } from '../node_modules/chai/chai.js'; -import sinon from '../node_modules/sinon/pkg/sinon-esm.js'; +import { expect } from 'chai'; +import sinon from 'sinon'; import Keyboard from '../core/input/keyboard.js'; diff --git a/tests/test.localization.js b/tests/test.localization.js index 2d05d1c6..9678f2d3 100644 --- a/tests/test.localization.js +++ b/tests/test.localization.js @@ -1,6 +1,6 @@ import './assertions.js'; -import { expect } from '../node_modules/chai/chai.js'; -import sinon from '../node_modules/sinon/pkg/sinon-esm.js'; +import { expect } from 'chai'; +import sinon from 'sinon'; import _, { Localizer, l10n } from '../app/localization.js'; diff --git a/tests/test.raw.js b/tests/test.raw.js index 2c62916d..aff9384f 100644 --- a/tests/test.raw.js +++ b/tests/test.raw.js @@ -1,5 +1,5 @@ import './assertions.js'; -import { expect } from '../node_modules/chai/chai.js'; +import { expect } from 'chai'; import Websock from '../core/websock.js'; import Display from '../core/display.js'; diff --git a/tests/test.rfb.js b/tests/test.rfb.js index e7c55b28..3cf8fcd8 100644 --- a/tests/test.rfb.js +++ b/tests/test.rfb.js @@ -1,6 +1,6 @@ import './assertions.js'; -import { expect } from '../node_modules/chai/chai.js'; -import sinon from '../node_modules/sinon/pkg/sinon-esm.js'; +import { expect } from 'chai'; +import sinon from 'sinon'; import RFB from '../core/rfb.js'; import Websock from '../core/websock.js'; diff --git a/tests/test.rre.js b/tests/test.rre.js index 9ad931bc..d16a26e1 100644 --- a/tests/test.rre.js +++ b/tests/test.rre.js @@ -1,5 +1,5 @@ import './assertions.js'; -import { expect } from '../node_modules/chai/chai.js'; +import { expect } from 'chai'; import Websock from '../core/websock.js'; import Display from '../core/display.js'; diff --git a/tests/test.tight.js b/tests/test.tight.js index bfa30d64..2162dd0f 100644 --- a/tests/test.tight.js +++ b/tests/test.tight.js @@ -1,5 +1,5 @@ import './assertions.js'; -import { expect } from '../node_modules/chai/chai.js'; +import { expect } from 'chai'; import Websock from '../core/websock.js'; import Display from '../core/display.js'; diff --git a/tests/test.tightpng.js b/tests/test.tightpng.js index a52cfd5d..cac586d6 100644 --- a/tests/test.tightpng.js +++ b/tests/test.tightpng.js @@ -1,5 +1,5 @@ import './assertions.js'; -import { expect } from '../node_modules/chai/chai.js'; +import { expect } from 'chai'; import Websock from '../core/websock.js'; import Display from '../core/display.js'; diff --git a/tests/test.util.js b/tests/test.util.js index f836f4b2..766e51ed 100644 --- a/tests/test.util.js +++ b/tests/test.util.js @@ -1,7 +1,7 @@ /* eslint-disable no-console */ import './assertions.js'; -import { expect } from '../node_modules/chai/chai.js'; -import sinon from '../node_modules/sinon/pkg/sinon-esm.js'; +import { expect } from 'chai'; +import sinon from 'sinon'; import * as Log from '../core/util/logging.js'; import { encodeUTF8, decodeUTF8 } from '../core/util/strings.js'; diff --git a/tests/test.websock.js b/tests/test.websock.js index 3509b36e..f1340490 100644 --- a/tests/test.websock.js +++ b/tests/test.websock.js @@ -1,6 +1,6 @@ import './assertions.js'; -import { expect } from '../node_modules/chai/chai.js'; -import sinon from '../node_modules/sinon/pkg/sinon-esm.js'; +import { expect } from 'chai'; +import sinon from 'sinon'; import Websock from '../core/websock.js'; import FakeWebSocket from './fake.websocket.js'; diff --git a/tests/test.webutil.js b/tests/test.webutil.js index 6046c3f0..4bea3ca5 100644 --- a/tests/test.webutil.js +++ b/tests/test.webutil.js @@ -1,8 +1,8 @@ /* jshint expr: true */ import './assertions.js'; -import { expect } from '../node_modules/chai/chai.js'; -import sinon from '../node_modules/sinon/pkg/sinon-esm.js'; +import { expect } from 'chai'; +import sinon from 'sinon'; import * as WebUtil from '../app/webutil.js'; diff --git a/tests/test.zrle.js b/tests/test.zrle.js index 27e2a02c..a2203b10 100644 --- a/tests/test.zrle.js +++ b/tests/test.zrle.js @@ -1,5 +1,5 @@ import './assertions.js'; -import { expect } from '../node_modules/chai/chai.js'; +import { expect } from 'chai'; import Websock from '../core/websock.js'; import Display from '../core/display.js'; diff --git a/web-test-runner.config.mjs b/web-test-runner.config.mjs new file mode 100644 index 00000000..96901af2 --- /dev/null +++ b/web-test-runner.config.mjs @@ -0,0 +1,13 @@ +import { defaultReporter } from '@web/test-runner'; +import { summaryReporter } from '@web/test-runner'; + +export default { + nodeResolve: true, + files: [ + 'tests/test.*.js', + ], + reporters: [ + defaultReporter(), + summaryReporter(), + ] +}; \ No newline at end of file