metaltest/lib/metaltest.test.js

29 lines
878 B
JavaScript
Raw Normal View History

2022-11-08 22:29:58 -05:00
import assert from 'node:assert/strict'
2022-12-05 22:21:18 -05:00
import { metaltest } from '../index.js'
2022-11-08 22:29:58 -05:00
const test = metaltest('Metaltest')
2022-12-05 22:21:18 -05:00
export { test }
2022-11-08 22:29:58 -05:00
test('success', () => new Promise((s, f) => setTimeout(s, 500)))
2022-12-06 19:56:49 -05:00
test('not equal', () => assert.notDeepEqual({ a: 1 }, { a: 2 }))
2022-11-08 22:29:58 -05:00
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' })
})
2022-12-30 13:42:42 -05:00
test.skip('skip', () => { })
2022-11-08 22:29:58 -05:00
2022-12-06 20:03:40 -05:00
test.end('verify', async (stats) => {
2022-11-08 22:29:58 -05:00
assert.equal(stats.success, 4)
assert.equal(stats.fail, 0)
2022-12-30 13:42:42 -05:00
assert.equal(stats.skip, 1)
2022-12-05 22:22:58 -05:00
assert.equal(stats.total, 4)
assert.equal(stats.title, 'Metaltest')
2022-12-06 20:03:40 -05:00
assert.equal(stats.testSuccess.length, 4)
assert.equal(stats.testFail.length, 0)
2022-11-08 22:29:58 -05:00
})
2022-12-06 20:03:40 -05:00
2023-09-30 04:59:01 -04:00
import { runifmain } from '../index.js'
await runifmain(import.meta, test)