diff --git a/lib/suite.js b/lib/suite.js index 0fba677..dbbf2c6 100644 --- a/lib/suite.js +++ b/lib/suite.js @@ -1,11 +1,12 @@ import path from 'node:path' import { walkDir } from './walkDir.js' -import { summaryreporter, errorreporter, totalreporter } from 'metaltest' +import { summaryreporter, totalreporter, totalerrorreporter } from 'metaltest' const suite = async (folder = '.') => { const fileIgnored = [] const total = totalreporter() + const error = totalerrorreporter() for await (const file of walkDir(folder, ['node_modules', '.git'])) { if (!file.endsWith('.test.js')) continue @@ -18,13 +19,14 @@ const suite = async (folder = '.') => { continue } - await test.run(summaryreporter(), errorreporter(), total) + await test.run(summaryreporter(), error, total) } for (const file of fileIgnored) { console.log(`The file ${file} doesn't export the metaltest object`) } + error.msg() console.log(total.msg()) } diff --git a/reporter/index.js b/reporter/index.js index 72f3907..a2162eb 100644 --- a/reporter/index.js +++ b/reporter/index.js @@ -2,4 +2,5 @@ export { summaryreporter } from './summaryreporter.js' export { linereporter } from './linereporter.js' export { totalreporter } from './totalreporter.js' export { errorreporter } from './errorreporter.js' +export { totalerrorreporter } from './totalerrorreporter.js' export { endreporter } from './endreporter.js' diff --git a/reporter/totalerrorreporter.js b/reporter/totalerrorreporter.js new file mode 100644 index 0000000..389c610 --- /dev/null +++ b/reporter/totalerrorreporter.js @@ -0,0 +1,16 @@ +import { showError } from "./showError.js" + +const totalerrorreporter = () => { + const testFails = [] + + const report = { + end: (stats) => testFails.push(...stats.testFail), + msg: () => { + showError(testFails) + }, + } + + return report +} + +export { totalerrorreporter }