Skip to content

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

Closed
@shanplourde

Description

@shanplourde

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions