JavaScript testing that just works.
Luna is a simple, modern, opinionated testing framework for JavaScript that has no configuration.
Yes, you read that right. You can get started and have your first tests running in less than a minute.
Getting started
Install Luna
npm install luna-testing
Add a test
Place this code in test/my-first-test.js
export function testThatLunaWorks(t) {
const pizza = 'good';
t.assert(pizza === 'good', 'Make sure that pizza is good!');
}
Run the test
npx luna test/my-first-test.js
You can also access the executable at ./node_modules/.bin/luna
To see what happens if a test fails change pizza to be bad!
Features
- Supports ES6 modules out of the box and automatically bundles them
- Runs tests in a browser by default
- Allows test functions to be exported from anywhere in your codebase including source files
- Supports concurrency to run test groups in parallel
- Generates code coverage reports without having to install any other modules
- Converts JSX code directly into
React.createElement
syntax - Uses a special
assert
function to provide meaningful errors when tests fail - Applies sourcemaps to error stack traces and code coverage reports automatically
- Supports array and object comparisons automatically when using
==
and!=
. - Uses Luna to test Luna (test inception!)
More Information
Check out the introductory blog post to learn about the inspiration behind Luna.
View the complete documentation on GitHub