Make eltro slightly more robust
Make the printError slightly more robust as well as well as make it print better when obscure errors occur when programmers fiddle with the internal mechanics of node, for example the Error.prepareStack among other things.
This commit is contained in:
parent
a571b95f90
commit
3bd8d4ba51
4 changed files with 28 additions and 2 deletions
3
cli.mjs
3
cli.mjs
|
@ -62,4 +62,7 @@ cli.processTargets().then(function() {
|
||||||
})
|
})
|
||||||
.then(function() {
|
.then(function() {
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
|
}, function(err) {
|
||||||
|
console.error('\x1b[31mInternal error occured:\x1b[0m', err)
|
||||||
|
process.exit(2)
|
||||||
})
|
})
|
||||||
|
|
|
@ -173,6 +173,6 @@ export function printError(err, msg) {
|
||||||
console.error('\x1b[31m '
|
console.error('\x1b[31m '
|
||||||
+ before + err.toString()
|
+ before + err.toString()
|
||||||
+ '\x1b[0m\n \x1b[90m'
|
+ '\x1b[0m\n \x1b[90m'
|
||||||
+ err.stack.replace(err.toString(), ''))
|
+ (err.stack || '').replace(err.toString(), ''))
|
||||||
console.error('\x1b[0m')
|
console.error('\x1b[0m')
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "eltro",
|
"name": "eltro",
|
||||||
"version": "1.0.1",
|
"version": "1.0.2",
|
||||||
"description": "Eltro is a tiny no-dependancy test framework for node",
|
"description": "Eltro is a tiny no-dependancy test framework for node",
|
||||||
"main": "index.mjs",
|
"main": "index.mjs",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -26,3 +26,26 @@ e.test('Eltro should support any value in promise fail', async function() {
|
||||||
assert.ok(t.failedTests[x].error.stack)
|
assert.ok(t.failedTests[x].error.stack)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
e.test('Eltro should support any value in throws', async function() {
|
||||||
|
const t = CreateT()
|
||||||
|
t.begin()
|
||||||
|
t.describe('', function() {
|
||||||
|
t.test('a', function() { throw null })
|
||||||
|
t.test('b', function() { throw {} })
|
||||||
|
t.test('c', function() { throw { message: 'test' } })
|
||||||
|
t.test('d', function() { throw 1234 })
|
||||||
|
t.test('e', async function() { throw null })
|
||||||
|
t.test('f', async function() { throw {} })
|
||||||
|
t.test('g', async function() { throw { message: 'test' } })
|
||||||
|
t.test('h', async function() { throw 1234 })
|
||||||
|
})
|
||||||
|
await t.run()
|
||||||
|
assert.strictEqual(t.failedTests.length, 8)
|
||||||
|
|
||||||
|
for (let x = 0; x < t.failedTests.length; x++) {
|
||||||
|
assert.strictEqual(typeof(t.failedTests[x].error), 'object')
|
||||||
|
assert.ok(t.failedTests[x].error.message)
|
||||||
|
assert.ok(t.failedTests[x].error.stack)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in a new issue