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

Error running image diff: Unknown Error #272

Closed k4y4k closed 3 years ago

k4y4k commented 3 years ago

howdy :wave:

First time using this. My snapshots generate OK but they won't test - if the snapshot exists, toMatchSnapshot() throws:

Error running image diff: Unknown Error 
    "jest": "26.6.3",
    "jest-image-snapshot": "4.5.0",

Any ideas?

nellyk commented 3 years ago

could you please provide code samples or a link to the repo

lukasvan3l commented 3 years ago

I believe I have the same issue. Here's a small repo to reproduce: https://github.com/lukasvan3l/jest-image-snapshot-invalid-snapshot

I'm getting a different errormessage because I set runInProcess: true in the config.

First round:

➜  jest-image-snapshot-invalid-snapshot git:(main) ✗ npm t

> jest-image-snapshot-invalid-snapshot@1.0.0 test
> jest

 PASS  tests/compare-png.test.js
  compare
    ✓ should snapshot my png (4 ms)

 › 1 snapshot written.
Snapshot Summary
 › 1 snapshot written from 1 test suite.

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   1 written, 1 total
Time:        0.536 s, estimated 1 s
Ran all test suites.

Second round:

➜  jest-image-snapshot-invalid-snapshot git:(main) ✗ npm t

> jest-image-snapshot-invalid-snapshot@1.0.0 test
> jest

 FAIL  tests/compare-png.test.js
  compare
    ✕ should snapshot my png (6 ms)

  ● compare › should snapshot my png

    Invalid file signature

      1 | describe('compare', () => {
      2 |   it('should snapshot my png', () => {
    > 3 |     expect('huis-aan-huis-1-2.png').toMatchImageSnapshot();
        |                                     ^
      4 |   })
      5 | })
      6 |

      at Object.<anonymous>.module.exports.Object.<anonymous>.Parser._parseSignature (node_modules/pngjs/lib/parser.js:53:18)
      at Object.<anonymous> (tests/compare-png.test.js:3:37)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        0.561 s, estimated 1 s
Ran all test suites.

The snapshot that is created is a whopping 21 bytes, that can't be right...

k4y4k commented 3 years ago

could you please provide code samples or a link to the repo

Unfortunately it's a private project. I did eventually implement visual diffing, but I'm not sure what I did that made it work or if I'm even using this plugin anymore 🤔

Forgot to close this, anyway, so apologies for that.