2022-12-04 23:40:07 -05:00
|
|
|
import assert from 'node:assert/strict'
|
2022-12-05 22:21:18 -05:00
|
|
|
import { metaltest } from '../index.js'
|
2022-12-05 16:50:01 -05:00
|
|
|
import { stackParser } from './stackparser.js'
|
2022-12-04 23:40:07 -05:00
|
|
|
|
|
|
|
const test = metaltest('Stack parser')
|
2022-12-05 22:21:18 -05:00
|
|
|
export { test }
|
2022-12-04 23:40:07 -05:00
|
|
|
|
|
|
|
test('Diff', () => {
|
|
|
|
try {
|
|
|
|
assert.deepEqual({ name: 'Name' }, { name: 'Name2' })
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
const stack = stackParser(e.stack)
|
2022-12-07 19:27:53 -05:00
|
|
|
assert.equal(stack.title, 'AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:')
|
2022-12-04 23:40:07 -05:00
|
|
|
assert.ok(stack.diff.includes("name: 'Name'"))
|
|
|
|
assert.ok(stack.diff.includes("name: 'Name2'"))
|
2022-12-07 19:27:53 -05:00
|
|
|
assert.equal(stack.where, 'at Object.fn (file:///home/taz/code/metaltest/lib/stackparser.test.js:10:12)')
|
|
|
|
assert.equal(stack.file, '/home/taz/code/metaltest/lib/stackparser.test.js')
|
|
|
|
assert.equal(stack.line, '10')
|
|
|
|
assert.equal(stack.column, '12')
|
|
|
|
assert.ok(stack.stacktrace.startsWith(' at Object.fn (file:///home/taz/code/metaltest/lib/stackparser.test.js:10:12)'))
|
2022-12-04 23:40:07 -05:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2022-12-05 22:26:51 -05:00
|
|
|
import { runifmain, summaryreporter } from '../index.js'
|
|
|
|
await runifmain(import.meta, () => test.run(summaryreporter()))
|