Files
2024-02-15 17:01:50 +00:00

24 lines
531 B
JavaScript

/* eslint-env node */
const fs = require('node:fs');
const path = require('node:path');
module.exports = results => {
if (!results.success) {
throw new Error('Balance reporter requires all tests to succeed.');
}
const cwd = process.cwd();
const testValues = {};
for (const test of results.testResults) {
testValues[test.testFilePath.replace(cwd, '')] = test.perfStats.runtime;
}
fs.writeFileSync(
path.resolve(__dirname, 'jest-balance.json'),
JSON.stringify(testValues)
);
return results;
};