metaltest/lib/stackparser.test.js

27 lines
1.1 KiB
JavaScript

import assert from 'node:assert/strict'
import { metaltest } from '../index.js'
import { stackParser } from './stackparser.js'
const test = metaltest('Stack parser')
export { test }
test('Diff', () => {
try {
assert.deepEqual({ name: 'Name' }, { name: 'Name2' })
}
catch (e) {
const stack = stackParser(e.stack)
assert.equal(stack.title, 'AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:')
assert.ok(stack.diff.includes("name: 'Name'"))
assert.ok(stack.diff.includes("name: 'Name2'"))
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)'))
}
})
import { runifmain, summaryreporter, errorreporter } from '../index.js'
await runifmain(import.meta, () => test.run(summaryreporter(), errorreporter()))