haim-io / cypress-image-diff

Visual regression test with cypress
MIT License
251 stars 62 forks source link

Intermittent Error: ENOENT: no such file or directory, open '/a/b/foo.png' #209

Closed ajbarber closed 7 months ago

ajbarber commented 7 months ago

Thanks for cypress-image-diff

Intermittently receiving this error when running layout tests:

> ENOENT: no such file or directory, open '/a/b/foo.png'
[2024-02-15T11:46:51.871Z] 
[2024-02-15T11:46:51.871Z] https://on.cypress.io/api/task
[2024-02-15T11:46:51.871Z]       at <unknown> (http://localhost:3000/__cypress/runner/cypress_runner.js:134597:70)
[2024-02-15T11:46:51.871Z]       at tryCatcher (http://localhost:3000/__cypress/runner/cypress_runner.js:1807:23)
[2024-02-15T11:46:51.871Z]       at Promise._settlePromiseFromHandler (http://localhost:3000/__cypress/runner/cypress_runner.js:1519:31)
[2024-02-15T11:46:51.871Z]       at Promise._settlePromise (http://localhost:3000/__cypress/runner/cypress_runner.js:1576:18)
[2024-02-15T11:46:51.871Z]       at Promise._settlePromise0 (http://localhost:3000/__cypress/runner/cypress_runner.js:1621:10)
[2024-02-15T11:46:51.871Z]       at Promise._settlePromises (http://localhost:3000/__cypress/runner/cypress_runner.js:1697:18)
[2024-02-15T11:46:51.871Z]       at _drainQueueStep (http://localhost:3000/__cypress/runner/cypress_runner.js:2407:12)
[2024-02-15T11:46:51.871Z]       at _drainQueue (http://localhost:3000/__cypress/runner/cypress_runner.js:2400:9)
[2024-02-15T11:46:51.871Z]       at Async._drainQueues (http://localhost:3000/__cypress/runner/cypress_runner.js:2416:5)
[2024-02-15T11:46:51.871Z]       at Async.drainQueues (http://localhost:3000/__cypress/runner/cypress_runner.js:2286:14)
[2024-02-15T11:46:51.871Z]   From Your Spec Code:
[2024-02-15T11:46:51.871Z]       at eval (http://localhost:3000/__cypress/tests?p=cypress/support/index.js:5534:23)
[2024-02-15T11:46:51.871Z]       at Context.cypressRecurse (http://localhost:3000/__cypress/tests?p=cypress/support/index.js:5248:26)
[2024-02-15T11:46:51.871Z]   
[2024-02-15T11:46:51.871Z]   From Node.js Internals:
[2024-02-15T11:46:51.871Z]     Error: ENOENT: no such file or directory, open '/a/b/foo.png'
[2024-02-15T11:46:51.871Z] 
[2024-02-15T11:46:51.871Z] 

I've traced it down to this line, ultimately the Cypress screenshot operation can fail or not complete before Cypress' defaultCommandTimeout.

Fixing this will allow cypress-recurse to proceed and have another go at the comparison.