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

Browser report fails when node_modules are read-only #848

Open
singles opened this issue Sep 9, 2018 · 4 comments
Open

Browser report fails when node_modules are read-only #848

singles opened this issue Sep 9, 2018 · 4 comments

Comments

@singles
Copy link

singles commented Sep 9, 2018

Description of a problem

In environments where node_modules are read-only browser report isn't created.

Examples of such environments: nix based builds, where node_modules land in /nix/store as read-only (555 or 444 rights).
Another one might be some stateless build systems, where node_modules is passed between build steps as an artifact and also might be read-only.

How to reproduce:

mkdir test && cd test
npm init -y && npm install backstopjs
./node_modules/.bin/backstop init
chmod -w ./node_modules/.bin/backstop/compare/output # simulate read-only case
./node_modules/.bin/backstop test
...

report | 2 Failed
       report | Writing browser report
       report | Failed writing report with error: undefined # <-- this

Potential cause

I dug a little into the internals and it looks that it's caused by

return fs.copy(config.comparePath, toAbsolute(config.html_report)).then(function () {

where fs.copy copies output with directory rights. Assuming I'm not wrong about how *nix systems handle permissions, in presented case, there's no write for output directory - thus no new directories html_report directory on the project side can be created as part of copy.

Workarounds

One workaround is to create directory structure before running tests, something like:

rm -rf backstop_data/html_report && mkdir -p backstop_data/html_report/fonts/assets

Summary

Not sure whether it should be considered as a bug, I just wanted to point out that current implementation might be causing some issues.

@lo1tuma
Copy link

lo1tuma commented Oct 29, 2018

I’ve stumbled upon the same problem. Additionally when creating the report fails the process exits with 0, which made our CI pipeline silently pass, even though the tests were actually failing.

@lo1tuma
Copy link

lo1tuma commented Oct 29, 2018

This might be an issue of fs-extra which preservers the permissions of copied files.

@XjSv
Copy link

XjSv commented Mar 12, 2022

I am also just running into this problem when packaging in using Electron. The files get packaged in \release\build\win-ia32-unpacked\resources\app.asar\node_modules\backstopjs\compare\output which is a read-only archive.

@XjSv
Copy link

XjSv commented Mar 12, 2022

I am using the code from #1400 for my Electron project and I am passing the comparePath in my config like so:

"comparePath": ${backstopDataDir}/compare/output,

It seems to be working at the moment.

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

No branches or pull requests

3 participants