Testing - novnc/noVNC GitHub Wiki

Running Tests

There are two types of tests in noVNC: manual test pages and automated Mocha tests.

Manual Tests

The manual test pages take the form of HTML files (although some of the HTML files are used for running Mocha tests -- see below). They can be run by simply opening them up in a web browser and interacting with them.

The goal is that the HTML files should be self-explanatory and any instructions for how to run the test should be included in the page itself.

Automatic Tests

First run npm install (not as root) at top level in your noVNC source code directory.

The tests take the form of Javascript files named test.*.js found in the /tests folder. We use Karma to run our tests. You can launch Karma manually, or simply run npm test. Then use a browser of your choosing and surf to the Karma server, see details in the output from the previous command. The Karma debug page will display the tests in normal mocha form, if you need it.

Requirements

The automatic tests require the Node Package Manager. On RPM systems, run sudo dnf install npm. On DPKG systems, run sudo apt install npm.

Writing Tests

New tests should be written using the Mocha test platform and the Chai assertion library. You do not need to do anything special to use these libraries in your tests. The tests should be placed in the tests directory, and should follow the naming convention of test.whatever_it_is_you_are_testing.js. There are several example tests to get you started.

Linter

We use ESLint to analyze the JavaScript code to flag for style errors. The rules are specified in .eslintrc. All new code must pass the linter. To start the lint check run npm run lint.