Skip to content

Helper attempts to confirm baseline and comparison images are accessible in write mode #75

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

Closed
shanplourde opened this issue Jul 8, 2020 · 2 comments

Comments

@shanplourde
Copy link
Contributor

shanplourde commented Jul 8, 2020

I'm trying to have Codecept's resemble-helper compare a read-only baseline file to a writable current file. The reason baseline files are read-only are because they are versioned in our version control system, and due to the file locking approach of our version control system (perforce) the files are always read-only until checked out.

The resemble-helper fails when attempting to open the read-only baseline file with a 'file is read-only' error

Console output of error occurring:

    I screenshot element ".fld-prop-lbl-length>i", "be-field-property-lbl-icon"
Error: C:\perforce-MDM.Next\MDM.Next\splourde_mdmui-config-app-main\mdmui-config-app-ui\e2e\output\resemble-screenshots\base/be-field-property-error-icon.png is read-only
Error: C:\perforce-MDM.Next\MDM.Next\splourde_mdmui-config-app-main\mdmui-config-app-ui\e2e\output\resemble-screenshots\base/be-field-property-error-icon.png is read-only
    at fs.access (C:\perforce-MDM.Next\MDM.Next\splourde_mdmui-config-app-main\mdmui-config-app-ui\e2e\node_modules\codeceptjs-resemblehelper\index.js:47:15)
    at FSReqWrap.args [as oncomplete] (fs.js:140:20)
Uncaught undefined exception

It looks like the issue lies in codeceptjs-resemblehelper/index.js, lines 44 - 57:

    // check whether the base and the screenshot images are present.
    fs.access(baseImage, fs.constants.F_OK | fs.constants.W_OK, (err) => {
      if (err) {
        throw new Error(
          `${baseImage} ${err.code === 'ENOENT' ? 'base image does not exist' : 'is read-only'}`);
      }
    });

    fs.access(actualImage, fs.constants.F_OK | fs.constants.W_OK, (err) => {
      if (err) {
        throw new Error(
          `${actualImage} ${err.code === 'ENOENT' ? 'screenshot image does not exist' : 'is read-only'}`);
      }
    });

I think that we just need to update this check to be F_OK | R_OK (write is not necessary for either file, I have confirmed this in a test run)

Details

  • CodeceptJS version: 2.6.1
  • codeceptjs-resemblehelper version: 1.9.1
  • Operating System: windows
shanplourde added a commit to shanplourde/codeceptjs-resemblehelper that referenced this issue Jul 8, 2020
@puneet0191
Copy link
Member

@shanplourde thanks a lot, could you please send PR so I could merge with next release.

puneet0191 added a commit that referenced this issue Oct 21, 2020
* support playwright helper (#81)

* Default to config.prepareBaseImage if no param specified (#79)

* Update index.js

We are only downloading the base image if the `options` param explicitly includes the option `{prepareBaseImage: false}`. Otherwise, it will omit downloading the base file, even if the helper configuration includes the prepareBaseImage option.

This change allows us to default to the value in the config file if the method doesn't receive that param.

* Update index.js

* Fix bug - baseline and comparison images write mode (#75) (#76)

* Prepare for 1.9.3 release

Co-authored-by: Peter Nguyen Tr <[email protected]>
Co-authored-by: Carlos <[email protected]>
Co-authored-by: Shan <[email protected]>
@puneet0191
Copy link
Member

This has been released and fixed, closing. thank you

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

2 participants