Its deveopers claim the Luna JavaScript unit test framework simplifies the testing process by not burdening developers with the task of configuration.

The new framework was built in response to dissatisfaction that Luna creator Craig Campbell had with other frameworks that require the writing of boilerplate code and have multiple configuration options. Inspired in part by the Go language’s built-in testing, Luna is an opinionated framework for testing JavaScript in a browser or Node.js. No global variables are required and there are no plugins. Also, no custom libraries are needed to run tests, with functions themselves extracted from code.

Luna’s limitations

Luna, however, does make some assumptions about the developer’s environment and does have certain requirements, with tests and code having to be written as ECMAScript 6 (2015) modules. And because Luna does not transpile source code with the exception of JSX, developers cannot use it with TypeScript or CoffeeScript. Also, tests will not run in older browsers.

Luna’s test process

The tool takes several steps in the test process:

Searches are done for functions whose names begin with test, which are exported from files and directories specified by a user.

The rollup API is used to create a bundle for tests in memory.

Test functions are called.

Results are communicated back to the main process via console logs.

Browser testing is built in and runs by default.

Code coverage reports are generated automatically.

Where to download Luna

You can download Luna from GitHub. Luna can be added to a project via NPM: npm install luna-testing.

Copyright 2018 IDG Communications. ABN 14 001 592 650. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of IDG Communications is prohibited.