{"id":17983575,"url":"https://github.com/vvscode/jest-coverage-issue-demo","last_synced_at":"2025-04-04T02:13:07.392Z","repository":{"id":233158943,"uuid":"724607576","full_name":"vvscode/jest-coverage-issue-demo","owner":"vvscode","description":"https://github.com/jestjs/jest/issues/14727","archived":false,"fork":false,"pushed_at":"2023-11-28T12:34:32.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-09T13:37:04.978Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/jestjs/jest/issues/14727","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vvscode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2023-11-28T12:34:08.000Z","updated_at":"2023-11-28T12:42:57.000Z","dependencies_parsed_at":"2024-04-14T07:54:50.967Z","dependency_job_id":"67c4ac59-e154-4543-b744-ec4f1bb2d7bb","html_url":"https://github.com/vvscode/jest-coverage-issue-demo","commit_stats":null,"previous_names":["vvscode/jest-coverage-issue-demo"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvscode%2Fjest-coverage-issue-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvscode%2Fjest-coverage-issue-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvscode%2Fjest-coverage-issue-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvscode%2Fjest-coverage-issue-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vvscode","download_url":"https://codeload.github.com/vvscode/jest-coverage-issue-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247107828,"owners_count":20884797,"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":[],"created_at":"2024-10-29T18:17:45.688Z","updated_at":"2025-04-04T02:13:07.375Z","avatar_url":"https://github.com/vvscode.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jest coverage issue demo\n\n## Case 1 - does not process global threshold if `collectCoverageFrom` is not set\n\n```\nnpx jest --config jest.config.js\n PASS  src/module/2.spec.js\n  two\n    ✓ returns 2 (1 ms)\n\n----------|---------|----------|---------|---------|-------------------\nFile      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s\n----------|---------|----------|---------|---------|-------------------\nAll files |     100 |      100 |     100 |     100 |\n 2.js     |     100 |      100 |     100 |     100 |\n----------|---------|----------|---------|---------|-------------------\nTest Suites: 1 passed, 1 total\nTests:       1 passed, 1 total\nSnapshots:   0 total\nTime:        0.252 s, estimated 1 s\n```\n\nwhile there are no tests for `src/1.js`.\n\nBy default [documentation](https://jestjs.io/docs/configuration#collectcoveragefrom-array) says\n\n\u003e This will collect coverage information for all the files inside the project's rootDir, except the ones that match **/node_modules/** or **/vendor/**.\n\n**Expected behavior:\"** - handle global coverage as \"50% doesn't met 100% expectation\"\n\n\n## Case 2 - on configured `collectCoverageFrom` it gives incorrect value for global\n\n```\n➜  jest-coverage-demo git:(master) ✗ npx jest --config jest.configWithCollectCoverageFrom.js\n PASS  src/module/2.spec.js\n  two\n    ✓ returns 2 (2 ms)\n\n------------|---------|----------|---------|---------|-------------------\nFile        | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s\n------------|---------|----------|---------|---------|-------------------\nAll files   |      50 |       50 |      50 |      50 |\n src        |       0 |        0 |       0 |       0 |\n  1.js      |       0 |        0 |       0 |       0 | 1-3\n src/module |     100 |      100 |     100 |     100 |\n  2.js      |     100 |      100 |     100 |     100 |\n------------|---------|----------|---------|---------|-------------------\nJest: \"global\" coverage threshold for statements (100%) not met: 0%\nJest: \"global\" coverage threshold for branches (100%) not met: 0%\nJest: \"global\" coverage threshold for lines (100%) not met: 0%\nJest: \"global\" coverage threshold for functions (100%) not met: 0%\nTest Suites: 1 passed, 1 total\nTests:       1 passed, 1 total\nSnapshots:   0 total\nTime:        0.331 s, estimated 1 s\n```\n\nit shows proper coverage for `All files` (50%), but error message below shows `0%` (`Jest: \"global\" coverage threshold for statements (100%) not met: 0%`)\n\n**Expected behavior:\"** - handle global coverage as \"50% doesn't met 100% expectation\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvvscode%2Fjest-coverage-issue-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvvscode%2Fjest-coverage-issue-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvvscode%2Fjest-coverage-issue-demo/lists"}