{"id":15434297,"url":"https://github.com/cenfun/jest-monocart-coverage","last_synced_at":"2025-04-19T18:09:19.235Z","repository":{"id":218545554,"uuid":"746229121","full_name":"cenfun/jest-monocart-coverage","owner":"cenfun","description":"A Jest custom reporter for monocart coverage reports","archived":false,"fork":false,"pushed_at":"2024-08-19T15:14:40.000Z","size":42,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-18T08:39:18.067Z","etag":null,"topics":["coverage","istanbul","jest","monocart","reporter","v8"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cenfun.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-21T13:09:29.000Z","updated_at":"2024-08-19T15:14:43.000Z","dependencies_parsed_at":"2024-01-24T06:50:20.290Z","dependency_job_id":"18016e4b-79a3-4c66-98a6-a1b2bab3d3f1","html_url":"https://github.com/cenfun/jest-monocart-coverage","commit_stats":{"total_commits":41,"total_committers":3,"mean_commits":"13.666666666666666","dds":0.04878048780487809,"last_synced_commit":"bbda75a73e40edf302273d93d90acb7bb79c0fbe"},"previous_names":["cenfun/jest-monocart-coverage","cenfun/jest-v8-coverage"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cenfun%2Fjest-monocart-coverage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cenfun%2Fjest-monocart-coverage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cenfun%2Fjest-monocart-coverage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cenfun%2Fjest-monocart-coverage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cenfun","download_url":"https://codeload.github.com/cenfun/jest-monocart-coverage/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249758757,"owners_count":21321590,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coverage","istanbul","jest","monocart","reporter","v8"],"created_at":"2024-10-01T18:38:41.705Z","updated_at":"2025-04-19T18:09:19.212Z","avatar_url":"https://github.com/cenfun.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jest-monocart-coverage\n[![](https://img.shields.io/npm/v/jest-monocart-coverage)](https://www.npmjs.com/package/jest-monocart-coverage)\n[![](https://badgen.net/npm/dw/jest-monocart-coverage)](https://www.npmjs.com/package/jest-monocart-coverage)\n![](https://img.shields.io/github/license/cenfun/jest-monocart-coverage)\n\n\n\u003e A [Jest](https://github.com/jestjs/jest/) custom reporter for [monocart coverage reports](https://github.com/cenfun/monocart-coverage-reports)\n\n## Install\n```sh\nnpm i jest-monocart-coverage\n```\n\n## Usage\n```js\n// jest.config.js\nconst config = {\n\n    // Enable coverage\n    collectCoverage: true,\n    // Recommended to use `v8` to support the generation of native v8 coverage reports.\n    coverageProvider: 'v8',\n    // Monocart can also support all coverage reports, so there is no need to set up reports here.\n    coverageReporters: ['none'],\n\n    reporters: [\n        // If custom reporters are specified, the default Jest reporter will be overridden. If you wish to keep it, 'default' must be passed as a reporters name:\n        'default',\n\n        // Monocart custom reporter to generate coverage reports. \n        ['jest-monocart-coverage', {\n            name: 'My Unit Coverage Report',\n            reports: [\n                ['v8'],\n                ['console-summary'],\n                ['lcovonly']\n            ],\n            outputDir: './coverage-reports/unit'\n        }]\n    ]\n    \n};\nexport default config;\n```\nCheck [monocart coverage reports](https://github.com/cenfun/monocart-coverage-reports) for more coverage options.\n\n## The Execution Order of Hooks\n- For Jest: custom reporter `onEnd` -\u003e `globalTeardown`\n- For Playwright: `globalTeardown` -\u003e coverage `onEnd` -\u003e custom reporter `onEnd`\n\n## Common issues\n- Resolve full path of the file with option `sourcePath` (issue [#5](https://github.com/cenfun/jest-monocart-coverage/issues/5))\n\n```js\nconst path = require(\"path\")\n\n// MCR coverage options\n{\n\n    sourcePath: (filePath, info)=\u003e {\n        if (!filePath.includes('/') \u0026\u0026 info.distFile) {\n            return `${path.dirname(info.distFile)}/${filePath}`;\n        }\n        return filePath;\n    }\n  \n}\n```\n\n- Failed to load Sourcemap (issue [#6](https://github.com/cenfun/jest-monocart-coverage/issues/6))\n\nUsing `sourceMap` instead of `inlineSourceMap` in `tsconfig.json`\n```json\n{\n    \"compilerOptions\": {\n        \"sourceMap\": true,\n        \"inlineSourceMap\": false\n    }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcenfun%2Fjest-monocart-coverage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcenfun%2Fjest-monocart-coverage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcenfun%2Fjest-monocart-coverage/lists"}