-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Testing
There are two types of tests in noVNC: manual test pages and automated Mocha 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 Mocha tests take the form of Javascript files named test.*.js
. They can be run two ways. The first is to run them using the run_from_console.js
script in the tests
directory. More information about this can be found below. The second way to run the Mocha tests is through a web browser. Some of the tests have also have pre-written HTML files that load and run them. You can open these files in your browser of choice to run the tests. For tests which do not have such files, you can use the -g
and/or -o
options to generate web pages to view (the former creates a temporary file which lasts until the program is terminated, while the latter just outputs the HTML source to STDOUT).
The tool run_from_console.js
is capable of running both collections of Mocha tests in HTML files, as well as Mocha tests in their direct Javascript form. For the former, run the following command:
$ tests/run_from_console.js -t tests/some_file.html
For the latter, you must also specify the Javascript files upon which the tests depend:
$ tests/run_from_console.js -t tests/test.something.js -i include/somefile.js
The run_from_console.js
tool also has additional options. Run it with --help
for more information.
The following NPM packages are needed to run the Mocha tests:
- chai (must be installed locally, used in tests)
- mocha (must be installed locally, used in tests)
- ansi (used in
run_from_console.js
) - commander (used in
run_from_console.js
) - temp (used in
run_from_console.js
)
Additionally, you will have to choose an environment for the run_from_console.js
tool. The default environment is CasperJS, which uses an isolated WebKit-based environment to realistically simulate a browser environment. To use CapserJS, you will need the following packages:
- casperjs (must be installed locally)
- phantomjs
- phantom
- spooky
The other environment is ZombieJS. ZombieJS is written purely in Javascript, and creates a fake DOM, so it is more lightweight, but less realistic. To use ZombieJS, you need to pass the -p zombie
option to the run_from_console.js
tool, and need the following packages:
- zombie
- q
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; they are automatically injected by the run_from_console.js
tool into the autogenerated web pages. 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. If you wish to see the actual Mocha test pages in a web browser, you can use the -g
and/or -o
options described above.
The wiki is read-only because of malware spam that GitHub refuses to provide protection agains. Contact the maintainers directly with changes you'd like to make.