Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
cenfun committed Jan 7, 2024
1 parent 138db12 commit 39042ea
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -697,33 +697,23 @@ export { test, expect };
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import EC from 'eight-colors';
import { addCoverageReport } from 'monocart-reporter';

export default async (config) => {

const dir = "your-v8-coverage-data-dir";

const files = fs.readdirSync(dir);
for (const filename of files) {
const content = fs.readFileSync(path.resolve(dir, filename)).toString('utf-8');
const json = JSON.parse(content);
let coverageList = json.result;

// filter node internal files
coverageList = coverageList.filter((entry) => entry.url && entry.url.startsWith('file:'));

if (!coverageList.length) {
continue;
}

// appending source content
coverageList.forEach((entry) => {
const filePath = fileURLToPath(entry.url);
if (fs.existsSync(filePath)) {
entry.source = fs.readFileSync(filePath).toString('utf8');
} else {
EC.logRed('not found file', filePath);
}
entry.source = fs.readFileSync(filePath).toString('utf8');
});

// there is no test info on teardown, just mock one with required config
Expand Down

0 comments on commit 39042ea

Please sign in to comment.