Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from Karma to Web Test Runner #1884

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ jobs:
- ubuntu-latest
- windows-latest
browser:
- ChromeHeadless
- FirefoxHeadless
- chrome
- firefox
include:
- os: macos-latest
browser: Safari
browser: safari
- os: windows-latest
browser: EdgeHeadless
browser: edge
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand Down
2 changes: 0 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ export default [
globals: {
...globals.node,
...globals.mocha,
sinon: false,
expect: false,
}
},
rules: {
Expand Down
92 changes: 0 additions & 92 deletions karma.conf.js

This file was deleted.

16 changes: 4 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -46,22 +46,14 @@
"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",
"@web/test-runner-webdriver": "latest"
},
"dependencies": {},
"keywords": [
"vnc",
"rfb",
Expand Down
8 changes: 2 additions & 6 deletions tests/assertions.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import * as chai from '../node_modules/chai/chai.js';
import sinon from '../node_modules/sinon/pkg/sinon-esm.js';
import sinonChai from '../node_modules/sinon-chai/lib/sinon-chai.js';
import * as chai from 'chai';
import sinonChai from 'sinon-chai';

window.expect = chai.expect;

window.sinon = sinon;
chai.use(sinonChai);

// noVNC specific assertions
Expand Down
2 changes: 2 additions & 0 deletions tests/test.base64.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect } from 'chai';

import Base64 from '../core/base64.js';

describe('Base64 Tools', function () {
Expand Down
2 changes: 2 additions & 0 deletions tests/test.browser.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect } from 'chai';

import { isMac, isWindows, isIOS, isAndroid, isChromeOS,
isSafari, isFirefox, isChrome, isChromium, isOpera, isEdge,
isGecko, isWebKit, isBlink } from '../core/util/browser.js';
Expand Down
3 changes: 3 additions & 0 deletions tests/test.copyrect.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import './assertions.js';
import { expect } from 'chai';

import Websock from '../core/websock.js';
import Display from '../core/display.js';

Expand Down
3 changes: 3 additions & 0 deletions tests/test.deflator.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import './assertions.js';
import { expect } from 'chai';

import { inflateInit, inflate } from "../vendor/pako/lib/zlib/inflate.js";
import ZStream from "../vendor/pako/lib/zlib/zstream.js";
import Deflator from "../core/deflator.js";
Expand Down
4 changes: 4 additions & 0 deletions tests/test.display.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import './assertions.js';
import { expect } from 'chai';
import sinon from 'sinon';

import Base64 from '../core/base64.js';
import Display from '../core/display.js';

Expand Down
4 changes: 4 additions & 0 deletions tests/test.gesturehandler.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import './assertions.js';
import { expect } from 'chai';
import sinon from 'sinon';

import EventTargetMixin from '../core/util/eventtarget.js';

import GestureHandler from '../core/input/gesturehandler.js';
Expand Down
2 changes: 2 additions & 0 deletions tests/test.helper.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect } from 'chai';

import keysyms from '../core/input/keysymdef.js';
import * as KeyboardUtil from "../core/input/util.js";

Expand Down
3 changes: 3 additions & 0 deletions tests/test.hextile.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import './assertions.js';
import { expect } from 'chai';

import Websock from '../core/websock.js';
import Display from '../core/display.js';

Expand Down
3 changes: 3 additions & 0 deletions tests/test.inflator.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import './assertions.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";
import Inflator from "../core/inflator.js";
Expand Down
2 changes: 2 additions & 0 deletions tests/test.int.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expect } from 'chai';

import { toUnsigned32bit, toSigned32bit } from '../core/util/int.js';

describe('Integer casting', function () {
Expand Down
3 changes: 3 additions & 0 deletions tests/test.jpeg.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import './assertions.js';
import { expect } from 'chai';

import Websock from '../core/websock.js';
import Display from '../core/display.js';

Expand Down
6 changes: 5 additions & 1 deletion tests/test.keyboard.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import './assertions.js';
import { expect } from 'chai';
import sinon from 'sinon';

import Keyboard from '../core/input/keyboard.js';

describe('Key Event Handling', function () {
Expand Down Expand Up @@ -591,7 +595,7 @@ describe('Key Event Handling', function () {
expect(kbd.onkeyevent).to.have.been.calledWith(0xffe1, 'ShiftLeft', true);
kbd.onkeyevent.resetHistory();

kbd._handleKeyDown(keyevent('keydown', {code: 'ShiftRight', key: 'Shift', location: 2}));
kbd._handleKeyDown(keyevent('keydown', {code: 'ShiftRight', key: 'ShiftFoo', location: 2}));
expect(kbd.onkeyevent).to.have.been.calledOnce;
expect(kbd.onkeyevent).to.have.been.calledWith(0xffe2, 'ShiftRight', true);
kbd.onkeyevent.resetHistory();
Expand Down
4 changes: 4 additions & 0 deletions tests/test.localization.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import './assertions.js';
import { expect } from 'chai';
import sinon from 'sinon';

import _, { Localizer, l10n } from '../app/localization.js';

describe('Localization', function () {
Expand Down
3 changes: 3 additions & 0 deletions tests/test.raw.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import './assertions.js';
import { expect } from 'chai';

import Websock from '../core/websock.js';
import Display from '../core/display.js';

Expand Down
8 changes: 8 additions & 0 deletions tests/test.rfb.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import './assertions.js';
import { expect } from 'chai';
import sinon from 'sinon';

import RFB from '../core/rfb.js';
import Websock from '../core/websock.js';
import ZStream from "../vendor/pako/lib/zlib/zstream.js";
import { deflateInit, deflate, Z_DEFAULT_COMPRESSION } from "../vendor/pako/lib/zlib/deflate.js";
import { encodings } from '../core/encodings.js';
import { initLogging } from '../core/util/logging.js';
import { toUnsigned32bit } from '../core/util/int.js';
import { encodeUTF8 } from '../core/util/strings.js';
import KeyTable from '../core/input/keysym.js';
Expand Down Expand Up @@ -111,6 +116,9 @@ describe('Remote Frame Buffer Protocol Client', function () {

// Avoiding printing the entire Websock buffer on errors
Websock.prototype.inspect = function () { return "[object Websock]"; };

// Avoid spamming test output
initLogging('none');
});

after(function () {
Expand Down
3 changes: 3 additions & 0 deletions tests/test.rre.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import './assertions.js';
import { expect } from 'chai';

import Websock from '../core/websock.js';
import Display from '../core/display.js';

Expand Down
3 changes: 3 additions & 0 deletions tests/test.tight.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import './assertions.js';
import { expect } from 'chai';

import Websock from '../core/websock.js';
import Display from '../core/display.js';

Expand Down
3 changes: 3 additions & 0 deletions tests/test.tightpng.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import './assertions.js';
import { expect } from 'chai';

import Websock from '../core/websock.js';
import Display from '../core/display.js';

Expand Down
14 changes: 9 additions & 5 deletions tests/test.util.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
/* eslint-disable no-console */
import './assertions.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';

Expand All @@ -7,11 +11,11 @@ describe('Utils', function () {

describe('logging functions', function () {
beforeEach(function () {
sinon.spy(console, 'log');
sinon.spy(console, 'debug');
sinon.spy(console, 'warn');
sinon.spy(console, 'error');
sinon.spy(console, 'info');
sinon.stub(console, 'log');
sinon.stub(console, 'debug');
sinon.stub(console, 'warn');
sinon.stub(console, 'error');
sinon.stub(console, 'info');
});

afterEach(function () {
Expand Down
4 changes: 4 additions & 0 deletions tests/test.websock.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import './assertions.js';
import { expect } from 'chai';
import sinon from 'sinon';

import Websock from '../core/websock.js';
import FakeWebSocket from './fake.websocket.js';

Expand Down
8 changes: 8 additions & 0 deletions tests/test.webutil.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
/* jshint expr: true */

import './assertions.js';
import { expect } from 'chai';
import sinon from 'sinon';

import * as WebUtil from '../app/webutil.js';
import { initLogging } from '../core/util/logging.js';

describe('WebUtil', function () {
"use strict";
Expand Down Expand Up @@ -63,6 +68,9 @@ describe('WebUtil', function () {
before(function () {
chrome = window.chrome;
window.chrome = null;

// Avoid spamming test output
initLogging('none');
});
after(function () {
window.chrome = chrome;
Expand Down
3 changes: 3 additions & 0 deletions tests/test.zrle.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import './assertions.js';
import { expect } from 'chai';

import Websock from '../core/websock.js';
import Display from '../core/display.js';

Expand Down
Loading
Loading