add terminal runner
This commit is contained in:
parent
d9ea0f64a2
commit
2599af74bb
1 changed files with 19 additions and 10 deletions
|
@ -30,6 +30,7 @@ const process = ([name, tests]) => {
|
|||
} else if (failLen === len) {
|
||||
color = Red
|
||||
}
|
||||
|
||||
const header = `${style(name, Bold, color)} (${passLen}/${len})`
|
||||
|
||||
const text = results.map(result => {
|
||||
|
@ -50,27 +51,35 @@ const makeSummary = results => {
|
|||
]),
|
||||
[0, 0]
|
||||
)
|
||||
|
||||
return {
|
||||
passed,
|
||||
failed,
|
||||
toString() {
|
||||
const summary = `test result: ${failed}. ${passed} passed; ${failed} failed`
|
||||
|
||||
const failures = results
|
||||
.filter(result => result.failed.length)
|
||||
.flatMap(result => {
|
||||
return result.failed.map(({ description, error }) => {
|
||||
return ` ${result.name}::${description}\n${error.stack}`
|
||||
}).join('\n\n')
|
||||
}).join('\n\n')
|
||||
|
||||
const summary = `test result: ${failed}. ${passed} passed; ${failed} failed`
|
||||
.flatMap(result =>
|
||||
result.failed.map(({ description, error }) =>
|
||||
` ${result.name}::${description}\n${error.stack}`
|
||||
).join('\n\n')
|
||||
).join('\n\n')
|
||||
|
||||
return `failures:\n${failures}\n\n${summary}`
|
||||
}
|
||||
}
|
||||
}
|
||||
export const term = tests => {
|
||||
const suites = Object.entries(tests).map(process)
|
||||
suites.forEach(s => console.log(s.toString()))
|
||||
console.log(makeSummary(suites).toString())
|
||||
const results = Object.entries(tests).map(process)
|
||||
|
||||
return {
|
||||
results,
|
||||
toString() {
|
||||
const suites = results.map(r => r.toString())
|
||||
const summary = makeSummary(results).toString()
|
||||
return `${suites}\n${summary}`
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue