Skip to content

Commit

Permalink
update log message and test fail handling
Browse files Browse the repository at this point in the history
  • Loading branch information
75lb committed Aug 29, 2024
1 parent 5b0bbe0 commit 3d758cf
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ class TestRunner {

async * run () {
for (const test of this.tests) {
console.log(`${ansi.format('●', ['yellow'])} ${ansi.format(test.metadata.file, ['magenta'])} ${test.name}`)
await test.run()
yield test
console.log(`${ansi.format(test.metadata.file, ['magenta'])} ${test.name}`)
try {
await test.run()
} catch (err) {
console.error(err)
console.log(`${ansi.format(test.metadata.file, ['magenta'])} ${test.name} - ${ansi.format('Failed', ['red'])}`)
} finally {
yield test
}
}
}

Expand Down Expand Up @@ -79,8 +85,6 @@ class TestRunner {

this.tests = only.length ? only : tests
for await (const test of this.run()) {
process.stdout.write(ansi.cursor.up(1) + ansi.erase.inLine(2))
console.log(`${ansi.format('✔', ['green'])} ${ansi.format(test.metadata.file, ['magenta'])} ${test.name}`)
if (test.data) {
console.log(indent(os.EOL + util.inspect(test.data, { colors: true }) + os.EOL, ' '))
}
Expand Down

0 comments on commit 3d758cf

Please sign in to comment.