home shape

Testing: Foxx + Mocha = <3

Foxx + Mocha

Some of the most frequent questions by new programmers learning Foxx have been about testing. While the HTTP API can easily be tested with any HTTP client and any JavaScript code that can be isolated from the ArangoDB APIs could be tested in similar environments like Node.js or io.js, it was all but impossible to test Foxx apps inside ArangoDB.

The upcoming release of ArangoDB sets out to change this. As of version 2.6, ArangoDB Foxx will come with full support for Mocha tests allowing you to use the same test framework for your frontend code in the browser, your server-side code running on Node.js or io.js, and your backend logic in Foxx.

Mocha is the most popular test framework for Node.js and the browser. It offers BDD, TDD and QUnit style testing. Foxx Mocha tests can be executed via the HTTP API or directly from the web admin interface for a familiar spec output. ArangoDB 2.6 also ships with the assertion libraries

chai and expect.js already pre-installed and ready for use in your test cases, as well as the existing implementation of the CommonJS “assert” module also provided by other JavaScript environments like Node.js and io.js.

If you want to give Mocha testing a try before the 2.6 release the feature is also available in the latest development version of ArangoDB.

For more information on writing Foxx tests see the new recipe Testing Foxx apps using Mocha.

Alan Plum avatar 1418721602 92x92

Alan Plum

Alan is an experienced web developer who feels equally at home in the backend and frontend. At ArangoDB he works on everything regarding JavaScript, with a special focus on Foxx.

1 Comment

  1. nehem on October 31, 2019 at 5:14 am

    Thanks for this feature. It makes writing easier than I originally thought.

Leave a Comment





Get the latest tutorials, blog posts and news: