2022-11-05 16:03:00 -04:00
|
|
|
# metaltest
|
|
|
|
|
2022-11-08 22:42:26 -05:00
|
|
|
Clone of baretest with reporting
|
|
|
|
|
|
|
|
## How to use
|
|
|
|
|
|
|
|
```js
|
|
|
|
import assert from "node:assert/strict";
|
|
|
|
import metaltest from "metaltest";
|
2022-12-04 16:31:39 -05:00
|
|
|
const test = metaltest("Simple test");
|
2022-11-08 22:42:26 -05:00
|
|
|
test("test 1", () => {
|
|
|
|
assert.equal(1, 1);
|
|
|
|
});
|
|
|
|
test("test 2", () => {
|
|
|
|
assert.equal(2, 2);
|
|
|
|
});
|
|
|
|
|
|
|
|
const stats = await test.run();
|
|
|
|
/* Will return
|
|
|
|
{
|
|
|
|
title: 'Metaltest',
|
|
|
|
success: 2,
|
|
|
|
fail: 0,
|
|
|
|
total: 2,
|
|
|
|
testSuccess: [],
|
|
|
|
testFail: []
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
```
|
|
|
|
|
|
|
|
### How to report to the console
|
|
|
|
|
|
|
|
```js
|
|
|
|
const stats = await test.run(consolereporter());
|
|
|
|
```
|
|
|
|
|
2022-12-04 16:31:26 -05:00
|
|
|
## How to create a suite of test
|
2022-11-08 22:42:26 -05:00
|
|
|
|
|
|
|
test.js
|
|
|
|
|
|
|
|
```js
|
|
|
|
import assert from "node:assert/strict";
|
|
|
|
import metaltest from "metaltest";
|
2022-12-04 16:31:39 -05:00
|
|
|
const test = metaltest("Simple test");
|
2022-11-08 22:42:26 -05:00
|
|
|
test("test 1", () => {
|
|
|
|
assert.equal(1, 1);
|
|
|
|
});
|
|
|
|
export { test };
|
|
|
|
```
|
|
|
|
|
|
|
|
suite.js
|
|
|
|
|
|
|
|
```js
|
|
|
|
const { test } = await import("test.js");
|
|
|
|
await test.run(consolereporter());
|
|
|
|
```
|
2022-12-04 16:30:05 -05:00
|
|
|
|
|
|
|
## Hot to easily run a suite of multiple test
|
|
|
|
|
|
|
|
suite.js
|
|
|
|
|
|
|
|
```js
|
|
|
|
import { suite } from "metaltest";
|
|
|
|
await suite(); // Will run all test that are in the current folder recursively
|
|
|
|
```
|