Skip to content

Vitest error the coverage report (Unable to lookup source) #30511

Open
@wfpaisa

Description

@wfpaisa

Command

test

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

In the "This experimental unit testing" mode, when using coverage, the HTML coverage report does not display properly.

Minimal Reproduction

Steps:

  1. Install Angular 20

  2. Enable Vitest: https://angular.dev/guide/testing/unit-tests#

  3. Run: ng test --code-coverage

  4. In the auto-generated folder: dist/test-out/[path]/coverage/index.html

Image

Exception or Error

Unable to lookup source: /home/projects/angular/a20-vitest/dist/test-out/b3051492-863d-46fc-bc29-87425336cca6/src/app/app.ts (ENOENT: no such file or directory, open '/home/projects/angular/a20-vitest/dist/test-out/b3051492-863d-46fc-bc29-87425336cca6/src/app/app.ts')
Error: Unable to lookup source: /home/projects/angular/a20-vitest/dist/test-out/b3051492-863d-46fc-bc29-87425336cca6/src/app/app.ts (ENOENT: no such file or directory, open '/home/projects/angular/a20-vitest/dist/test-out/b3051492-863d-46fc-bc29-87425336cca6/src/app/app.ts')
    at Context.defaultSourceLookup [as sourceFinder] (/home/projects/angular/a20-vitest/node_modules/istanbul-lib-report/lib/context.js:17:15)
    at Context.getSource (/home/projects/angular/a20-vitest/node_modules/istanbul-lib-report/lib/context.js:71:21)
    at annotateSourceCode (/home/projects/angular/a20-vitest/node_modules/istanbul-reports/lib/html/annotator.js:249:40)
    at HtmlReport.onDetail (/home/projects/angular/a20-vitest/node_modules/istanbul-reports/lib/html/index.js:414:33)
    at Visitor.value (/home/projects/angular/a20-vitest/node_modules/istanbul-lib-report/lib/tree.js:38:38)
    at ReportNode.visit (/home/projects/angular/a20-vitest/node_modules/istanbul-lib-report/lib/tree.js:88:21)
    at /home/projects/angular/a20-vitest/node_modules/istanbul-lib-report/lib/tree.js:92:19
    at Array.forEach ()
    at ReportNode.visit (/home/projects/angular/a20-vitest/node_modules/istanbul-lib-report/lib/tree.js:91:28)
    at ReportTree.visit (/home/projects/angular/a20-vitest/node_modules/istanbul-lib-report/lib/tree.js:127:24)

Your Environment

Angular CLI: 20.0.1
Node: 22.16.0
Package Manager: npm 10.9.2
OS: linux x64

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions