Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to look up source error #147

Closed
3590Duncan opened this issue Mar 4, 2020 · 9 comments · Fixed by #197
Closed

Unable to look up source error #147

3590Duncan opened this issue Mar 4, 2020 · 9 comments · Fixed by #197

Comments

@3590Duncan
Copy link

When I click on a file in the coverage report I get an error indicating

Error: Unable to lookup source: /var/www/ui/components/booking/agenda/ActivityContainer.jsx(ENOENT: no such file or directory

We use docker to run our application locally. I am wondering if I need to mount the coverage or NYC folders in order for this data to be accessible?
I have attached a screenshot if the output

Screen Shot 2020-03-04 at 9 21 26 AM

@bahmutov
Copy link
Contributor

bahmutov commented Mar 4, 2020 via email

@josh-byster
Copy link

I have the same issue—right now I'm running:

docker-compose run -v "$(pwd)"/frontend:/var/temp prod-frontend /var/www/app/node_modules/.bin/nyc report --report-dir /var/temp/coverage --temp-dir /var/temp/.nyc_output --reporter=lcov --reporter=clover --reporter=json

Which is essentially running a container instance and then generating a coverage report in the container which then because it's mounted then gets transferred to the host. This is a workaround that works for me right now.

But the problem isn't that we're just mounting the tests. The problem (which I'm assuming is the same as @3590Duncan) is that the generated coverage report has paths like /var/www/ui/components but when we try to access those coverage reports locally outside the Docker container, the files may be at a path like /Users/josh/Documents/project/ui/components. Hence there's a mismatch because it's looking for /var/www/ui/components but that's the path inside the Docker container. So it would be really nice if somehow the paths can be rewritten.

@bahmutov
Copy link
Contributor

bahmutov commented Apr 17, 2020

Idea: if the source paths in .nyc_output/out.json are all "wrong" and cannot be found, maybe they are just from Docker instrumentation and really are present locally and should be found (before generating the report). Need to try this.

@bahmutov
Copy link
Contributor

🎉 This issue has been resolved in version 3.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@bahmutov
Copy link
Contributor

@josh-byster
Copy link

This looks like it works on my end after running within the CI environment instead of the container (much easier) and testing it with my Dockerized app. Thank you for adding this feature!

@Quasarman
Copy link

Hello,

I think I am currently facing a similiar issue that is not covered by this fix. I am also running the web application inside a docker contianer therefore the paths to the respective source files is not the same. They get replaced by the according absolute paths as described here when running the e2e tests for the first time. But when running them for the second time with e.g., a different user-agent configuration to simulate mobile behaviour, and this new configuration introduces files not included in the first run, their path is still the same as the path inside the docker container, leading to the described error:

Error
image

.nyc_output/out.json paths correctly replaced (first run without user-agent configuration)
image

.nyc_output/out.json paths not correctly replaced (second run with user-agent configuration, file was not part of first run)
image

The overall coverage report is then unable to find any source files introduced by the second (mobile config) run. Despite this the coverage behaviour of soure files present during both runs is as expected. Figure below shows if there is a condition leading to a branch that checks mobile behaviour it gets correctly merged with the first run ($Platform indicates if run on mobile device):
image

This leads me to the question: Are the paths in the out.json only checked and replaced for the first time e.g., if the files does not previously exist? How could I overcome this issue? Since I really like to have the complete coverage (desktop and mobile) runs merged in a single output to analyze.

I had a look at the source code but I'm a bit lost in there...

Thanks for any help

@Quasarman
Copy link

Maybe this has to do with checking if all the files are missing?

@Quasarman
Copy link

Update: This also seems to happen wen having multiple test files not just running the tests twice...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants