From 45153fc6e757fc3ce72cf90603c425dc0573c4c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Matte?= Date: Tue, 8 Nov 2022 22:42:26 -0500 Subject: [PATCH] How to use --- README.md | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c33a1e6..a2ce049 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,56 @@ # metaltest -Clone of baretest with reporting \ No newline at end of file +Clone of baretest with reporting + +## How to use + +```js +import assert from "node:assert/strict"; +import metaltest from "metaltest"; +const test = metaltest("Metaltest"); +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()); +``` + +### How to create a suite of test + +test.js + +```js +import assert from "node:assert/strict"; +import metaltest from "metaltest"; +const test = metaltest("Metaltest"); +test("test 1", () => { + assert.equal(1, 1); +}); +export { test }; +``` + +suite.js + +```js +const { test } = await import("test.js"); +await test.run(consolereporter()); +```