metaltest/lib/metaltest.test.js

29 lines
956 B
JavaScript

import assert from 'node:assert/strict'
import { metaltest } from '../index.js'
const test = metaltest('Metaltest')
export { test }
test('success', () => new Promise((s, f) => setTimeout(s, 500)))
test('not equal', () => assert.notDeepEqual({ a: 1 }, { a: 2 }))
test('fail with the message', () => new Promise((s, f) => setTimeout(s, 500)))
test('throw', () => {
return assert.rejects(async () => {
throw new Error('message')
}, { name: 'Error', message: 'message' })
})
test.skip('skip', () => { })
test.end('verify', async (stats) => {
assert.equal(stats.success, 4)
assert.equal(stats.fail, 0)
assert.equal(stats.skip, 1)
assert.equal(stats.total, 4)
assert.equal(stats.title, 'Metaltest')
assert.equal(stats.testSuccess.length, 4)
assert.equal(stats.testFail.length, 0)
})
import { runifmain, summaryreporter, errorreporter } from '../index.js'
await runifmain(import.meta, () => test.run(summaryreporter(), errorreporter()))