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) {
|
} else if (failLen === len) {
|
||||||
color = Red
|
color = Red
|
||||||
}
|
}
|
||||||
|
|
||||||
const header = `${style(name, Bold, color)} (${passLen}/${len})`
|
const header = `${style(name, Bold, color)} (${passLen}/${len})`
|
||||||
|
|
||||||
const text = results.map(result => {
|
const text = results.map(result => {
|
||||||
|
@ -50,27 +51,35 @@ const makeSummary = results => {
|
||||||
]),
|
]),
|
||||||
[0, 0]
|
[0, 0]
|
||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
passed,
|
passed,
|
||||||
failed,
|
failed,
|
||||||
toString() {
|
toString() {
|
||||||
|
const summary = `test result: ${failed}. ${passed} passed; ${failed} failed`
|
||||||
|
|
||||||
const failures = results
|
const failures = results
|
||||||
.filter(result => result.failed.length)
|
.filter(result => result.failed.length)
|
||||||
.flatMap(result => {
|
.flatMap(result =>
|
||||||
return result.failed.map(({ description, error }) => {
|
result.failed.map(({ description, error }) =>
|
||||||
return ` ${result.name}::${description}\n${error.stack}`
|
` ${result.name}::${description}\n${error.stack}`
|
||||||
}).join('\n\n')
|
).join('\n\n')
|
||||||
}).join('\n\n')
|
).join('\n\n')
|
||||||
|
|
||||||
const summary = `test result: ${failed}. ${passed} passed; ${failed} failed`
|
|
||||||
|
|
||||||
return `failures:\n${failures}\n\n${summary}`
|
return `failures:\n${failures}\n\n${summary}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const term = tests => {
|
export const term = tests => {
|
||||||
const suites = Object.entries(tests).map(process)
|
const results = Object.entries(tests).map(process)
|
||||||
suites.forEach(s => console.log(s.toString()))
|
|
||||||
console.log(makeSummary(suites).toString())
|
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