Simple test framework for Node.js
Contents
Installing
Using npm
:
$ npm install kreszentia --global
Getting Started
$ npm install kreszentia --global
$ mkdir __tests__ && cd __tests__
$ touch addition.js
In your editor:
import { equal } from "node:assert";
// Define a new suite
suite("addition", () => {
// Add a new test
add("add 1+1", () => {
equal(1 + 1, 3);
});
// Add a new test
add("add 2+2", () => {
equal(2 + 2, 4);
});
// Finish adding tests
done();
});
// Runs all suites.
run();
In the terminal:
$ kreszentia
addition:
✕ - add 1+1: expected 3, got 2
✓ - add 2+2
1 tests passing, 1 tests failing
As of version 1.1.0. kreszentia also supports require()
/import
:
const { suite, add, done, run } = require("kreszentia");
Or:
import { suite, add, done, run } from "kreszentia";
API
suite(suiteName, callback)
Creates a new test suite.
suiteName | string |
---|---|
callback | function |
add(testName, callback)
Adds a test to the current test suite.
testName | string |
---|---|
callback | function |
done()
Finish adding tests to the test suite.
run()
Run all suites.