americanexpress / jest-image-snapshot

✨ Jest matcher for image comparisons. Most commonly used for visual regression testing.
Apache License 2.0
3.81k stars 197 forks source link

The "path" argument must be of type string. Received undefined #300

Closed simonsmith closed 1 year ago

simonsmith commented 2 years ago

I believe a breaking change was introduced in https://github.com/americanexpress/jest-image-snapshot/pull/298

The diffImageToSnapshot function now accepts what appears to be an optional receivedDir prop but it has no default value so if I update from 5.0.0 to 5.1.0 I now get the above error because undefined is passed to path.join here:

const receivedSnapshotPath = path.join(receivedDir, `${snapshotIdentifier}-received.png`);

For reference, here is how I was calling it before so you can see how receivedDir is undefined

  snapshotResult = diffImageToSnapshot({
    snapshotsDir,
    diffDir,
    receivedImageBuffer,
    snapshotIdentifier,
    failureThreshold,
    failureThresholdType,
    updateSnapshot: updateSnapshots,
    ...options,
  });

I think that change should either be

For now, staying on 5.0.0 resolves it

Thanks!

MirandaBrawnerSavannah commented 1 year ago

Did you resolve this issue? If not, do you want me to work on it?

simonsmith commented 1 year ago

I just found a workaround, which was to stay on 5.0.0 of this library

oneamexbot commented 1 year ago

:tada: This issue has been resolved in version 5.1.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: