Testing 3rd-party code deprecated

How to add automatic testing to UI plugins

based on this oxpedia article


  • Mocha - the fun, simple, flexible JS testing framework
  • Sinon.JS - Standalone test spies, stubs and mocks for JavaScript.
  • Karma Runner - test runner
  • Chai.js - Assertion framework
  • karma-ox-ui - Running unit tests in AppSuite context

The shared grunt configuration ships with most of the parts pre-configured. Since we use many standard libraries, this approach can be extended as you wish.

Running the tests

There are multiple targets provided in shared grunt configuration.

The grunt/local.conf.json needs to be configured and point to an existing build of the core UI (coreDir setting). When testing on a machine with the core UI installed from distribution packages, also the German translations need to be installed to run the tests. After that, coreDir can be set to /opt/open-xchange/appsuite/.

development environment

The recommended way to start testing is to run:

grunt dev

This will start a connect server, the karma test server and a watcher for changes. Optionally, it is possible to connect multiple browsers to the host running the karma server (port 9876). Tests will run in those browsers, too. You can trigger a test run manually by running:

grunt testrun

in another terminal. This will be done automatically by the grunt watch task, after any source file of your project has been changed.

CI environment

In continuous integration (CI) environments, it is also possible to run grunt build copy:specs karma:continuous. When using yo ox-ui-module template, npm test defaults to this command, too.