Blame | Last modification | View Log | Download
# WWW Unit testsThis folder contains the unit tests for components in www._Be warned! This is a work in progres._## Tooling### mochaA tool called 'mocha' is used to drive the tests. The tests are writtenspecifically to be used with mocha. See: https://mochajs.org/It is not written in stone that mocha be used for unit testing. A differentframework can be used for different kind of tests.## Setup### InstallationAs the www-components are written in JavaScript, we need a JavaScriptengine to run on. For example, Node.js. See https://nodejs.org/en/. Makesure you have Node.js installed. Node.js comes with npm, which is thepackage manager that allows you to install different kind of packagesto use on your Node.js engine. For example, the mocha package.In short, follow the installation instructions on the mocha website. Butwhat it says basically is:`npm install --global mocha`## Usage### Structuremain.js - contains the requirejs module configuration. It should registerall the modules that the components under test use._path/component.js_ - the files containing the tests should be in thesame folder structure as the components under test are,relative to the 'www' folder.### Running the testRun the tests in a specific file with:`mocha _path_/test.js`For example, there is one test.js file in app/log. Run this with:`mocha app/log/test.js`It should display something like this:RefreshingDayChartconstructor√ should be instantiable1 passing (5ms)device -> idx:1234, type:Type, subtype:SubTypeinstalled:handler for event type time_updateIf the test runs fine, only the test output is displayed.If an error occurs, mocha will show the error and complete stacktrace.