Skip to content
Helmut Tammen edited this page Apr 28, 2016 · 1 revision

Testing

This document is in progress

For automtically testing our application we decided to use some commonly used tools by node.js developers. If you write tests for the n-odata-server we encourage you to use these tools.
Those are:

  • mocha as test framework. You have to install it globally
  • chai as assertion library. It is installed locally by the project

Writing tests

For writing tests just have a look into the test folder and see how we did our other tests.
If you have a better idea just discuss it with us in our Slack.

Running tests

To run the tests you simply execute

npm test

on the command line.

If you want to get the code coverage evaluated by istanbul you have to run

npm test --coverage

or

npm run coverage

The coverage data is saved in folder ./coverage. A html report of the coverage is saved in file ./coverage/lcov-report/index.html.

Debugging tests

To debug your tests in Chrome do the following.
Open a terminal and enter

node-inspector

(must have been installed, see link below for more details)
Open another terminal and enter

mocha --debug-brk test/**

Open Chrome an go to the URL
http://127.0.0.1:8080/?ws=127.0.0.1:8080&port=5858

After a few seconds the debugger should stop at the first line of code.

Useful links

Here are some useful links to get familiar with testing in detail.