{"id":16189669,"url":"https://github.com/stuk/wtr-coverage-repro","last_synced_at":"2026-02-07T08:31:20.289Z","repository":{"id":66062881,"uuid":"363249098","full_name":"Stuk/wtr-coverage-repro","owner":"Stuk","description":null,"archived":false,"fork":false,"pushed_at":"2021-04-30T20:40:28.000Z","size":48,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-07T01:29:57.876Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/istanbuljs/v8-to-istanbul/issues/121","language":"HTML","has_issues":false,"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/Stuk.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,"publiccode":null,"codemeta":null}},"created_at":"2021-04-30T20:15:03.000Z","updated_at":"2021-04-30T20:40:29.000Z","dependencies_parsed_at":"2023-06-15T03:30:49.467Z","dependency_job_id":null,"html_url":"https://github.com/Stuk/wtr-coverage-repro","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Stuk/wtr-coverage-repro","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stuk%2Fwtr-coverage-repro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stuk%2Fwtr-coverage-repro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stuk%2Fwtr-coverage-repro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stuk%2Fwtr-coverage-repro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Stuk","download_url":"https://codeload.github.com/Stuk/wtr-coverage-repro/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stuk%2Fwtr-coverage-repro/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29190174,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T07:37:03.739Z","status":"ssl_error","status_checked_at":"2026-02-07T07:37:03.029Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-10T07:36:21.205Z","updated_at":"2026-02-07T08:31:20.270Z","avatar_url":"https://github.com/Stuk.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Reproduction of WTR broken coverage bug\n\nThis repro shows how methods defined on a class with the arrow `=\u003e` syntax break the coverage report in WTR in certain situations.\n\nFor issues https://github.com/modernweb-dev/web/issues/689 and https://github.com/istanbuljs/v8-to-istanbul/issues/121\n\nTo reproduce run `npm install` then `npm test`, and open `coverage/lcov-report/bad.js.html`.\n\nInstead of coverage for the affected file, one will see:\n\n```\nCannot read property 'decl' of undefined\nTypeError: Cannot read property 'decl' of undefined\n    at /Users/xxxx/wtr-coverage-repro/node_modules/istanbul-reports/lib/html/annotator.js:89:31\n    at Array.forEach ()\n    at annotateFunctions (/Users/xxxx/wtr-coverage-repro/node_modules/istanbul-reports/lib/html/annotator.js:86:29)\n    at annotateSourceCode (/Users/xxxx/wtr-coverage-repro/node_modules/istanbul-reports/lib/html/annotator.js:234:9)\n    at HtmlReport.onDetail (/Users/xxxx/wtr-coverage-repro/node_modules/istanbul-reports/lib/html/index.js:409:33)\n    at LcovReport. [as onDetail] (/Users/xxxx/wtr-coverage-repro/node_modules/istanbul-reports/lib/lcov/index.js:28:23)\n    at Visitor.value (/Users/xxxx/wtr-coverage-repro/node_modules/istanbul-lib-report/lib/tree.js:38:38)\n    at ReportNode.visit (/Users/xxxx/wtr-coverage-repro/node_modules/istanbul-lib-report/lib/tree.js:88:21)\n    at /Users/xxxx/wtr-coverage-repro/node_modules/istanbul-lib-report/lib/tree.js:92:19\n    at Array.forEach ()\n```\n\nThe suspected cause of this bug is:\n\n1. Each test runs in its own context, and coverage is collected for all files which are loaded in each test run\n2. The metadata for functions in a file is stored from the _first_ run that included that file\n3. The coverage is combined from all test runs to produce the final coverage numbers\n4. Methods authored with the arrow syntax `=\u003e` are only defined at runtime when the constructor is executed, and if in point 2. the constructor in a file isn't executed, the metadata for those methods won't exist.\n\nIn this repro:\n\n* `1-test.js` loads `Good` through `index.js` which _also_ includes `Bad.js`.\n    - `Bad.js` is executed and so gains some coverage information, but `Bad`'s constructor is never executed, so point 4. above never occurs.\n    - The coverage information is collected, but metadata about `Bad.method` doesn't exist, because that function never did exist in this test run\n* `2-test.js` runs, and this does execute `Bad`'s constructor and so now there is coverage information for `Bad.method`\n* When the coverage details are generated, and the coverage of `Bad.method` is collated the metadata for `Bad.method` does not exist, because the metadata was only stored from the first run of `1-test.js`. This is what results in the above stack trace.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstuk%2Fwtr-coverage-repro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstuk%2Fwtr-coverage-repro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstuk%2Fwtr-coverage-repro/lists"}