ILIAS is using Mocha as test framework for Javascript unit tests. The esm
extension
allows to use ES6 modules seamlessly. Chai is being used as assertion library.
(not necessary as long as we keep npm modules in our git repo)
> npm i --save-dev mocha
> npm i --save-dev esm
> npm i --save-dev chai
The link to the mocha.config.js files that contains the tests is listed in package.json as such:
{
...
"scripts": {
"test": "mocha --recursive --config tests/mocha.config.js --require esm"
},
...
}
In tests/mocha.config.js file you can link your js test folders as such
module.exports = {
spec: [
'tests/UI/Client',
'docs/development/js/js-unit-test-example/test',
],
};
With this in place, the tests in the above dirs can be executed with:
> npm test
Your tests should be located in a subdirectory test
.