Add test suite

master
Frédéric Matte 2022-12-05 22:21:18 -05:00
parent 6927f40096
commit a46c2d73c8
4 changed files with 11 additions and 7 deletions

View File

@ -1,7 +1,8 @@
import assert from 'node:assert/strict' import assert from 'node:assert/strict'
import { metaltest, consolereporter } from '../index.js' import { metaltest } from '../index.js'
const test = metaltest('Metaltest') const test = metaltest('Metaltest')
export { test }
let count = 0 let count = 0
test.before(() => count++) test.before(() => count++)
@ -15,9 +16,7 @@ test('throw', () => {
}, { name: 'Error', message: 'message' }) }, { name: 'Error', message: 'message' })
}) })
export { test } import { runifmain, consolereporter } from '../index.js'
import { runifmain } from './runifmain.js'
await runifmain(import.meta, async () => { await runifmain(import.meta, async () => {
const stats = await test.run(consolereporter()) const stats = await test.run(consolereporter())
assert.equal(count, 4) assert.equal(count, 4)

View File

@ -1,8 +1,9 @@
import assert from 'node:assert/strict' import assert from 'node:assert/strict'
import { metaltest, consolereporter } from '../index.js' import { metaltest } from '../index.js'
import { stackParser } from './stackparser.js' import { stackParser } from './stackparser.js'
const test = metaltest('Stack parser') const test = metaltest('Stack parser')
export { test }
test('Diff', () => { test('Diff', () => {
try { try {
@ -16,4 +17,5 @@ test('Diff', () => {
} }
}) })
await test.run(consolereporter()) import { runifmain, consolereporter } from '../index.js'
await runifmain(import.meta, () => test.run(consolereporter()))

View File

@ -5,7 +5,7 @@
"type": "module", "type": "module",
"exports": "./index.js", "exports": "./index.js",
"scripts": { "scripts": {
"test": "node test.js" "test": "node suite.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

3
suite.js Normal file
View File

@ -0,0 +1,3 @@
import { suite } from './index.js'
await suite()