question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

toMatchImageSnapshot fails with Path must be a string. Received undefined

See original GitHub issue

We are trying to use your plugin and when we use the ImageSnapshot cypress throws an error.

Sample code:

cy.document().toMatchImageSnapshot()

The .png image snapshots are created correctly under __image_snapshots__ but the tests fail and cypress throws the following error:

CypressError: cy.task('cypress-plugin-snapshot:matchImage') failed with the following error:

> TypeError: Path must be a string. Received undefined
    at assertPath (path.js:28:11)
    at Object.relative (path.js:1267:5)
    at getImageData (/Users/ioanagalan/Templafy/Templafy.AutomatedQualityAssurance/CypressTests/node_modules/cypress-plugin-snapshots/src/utils/image/getImageData.js:8:24)
    at matchImageSnapshot (/Users/ioanagalan/Templafy/Templafy.AutomatedQualityAssurance/CypressTests/node_modules/cypress-plugin-snapshots/src/tasks/matchImageSnapshot.js:70:15)
    at invoke (/Users/ioanagalan/Library/Caches/Cypress/3.3.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/task.js:37:14)
    at /Users/ioanagalan/Library/Caches/Cypress/3.3.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:48:16
    at tryCatcher (/Users/ioanagalan/Library/Caches/Cypress/3.3.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
    at Function.Promise.attempt.Promise.try (/Users/ioanagalan/Library/Caches/Cypress/3.3.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/method.js:39:29)
    at Object.wrapChildPromise (/Users/ioanagalan/Library/Caches/Cypress/3.3.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:47:28)
    at Object.wrap (/Users/ioanagalan/Library/Caches/Cypress/3.3.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/task.js:43:8)
    at execute (/Users/ioanagalan/Library/Caches/Cypress/3.3.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:86:12)
    at EventEmitter.ipc.on (/Users/ioanagalan/Library/Caches/Cypress/3.3.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:136:5)
    at emitThree (events.js:136:13)
    at EventEmitter.emit (events.js:217:7)
    at process.<anonymous> (/Users/ioanagalan/Library/Caches/Cypress/3.3.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:25:29)
    at emitTwo (events.js:126:13)
    at process.emit (events.js:214:7)
    at emit (internal/child_process.js:772:12)
    at _combinedTickCallback (internal/process/next_tick.js:141:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

Cypress version: 3.3.1 cypress-plugin-snapshots version: 1.2.6 @cypress/snapshot version 2.1.3

Worth mentioning is that we are running on mac. Note: This only happens when screenshots do not exist and they are created for the first time.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
johnmcclumphacommented, Aug 14, 2019

thanks @meinaart - can confirm this release has fixed this issue 😃

0reactions
meinaartcommented, Aug 14, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

"Path must be a string. Received undefined" #144 - zkat/npx
npm v5.51 node v8.9.0 ... it seems that anytime I run an npx command it shows "Path must be a string. Received undefined"...
Read more >
Jest TypeError: Path must be a string. Received undefined
I solved this issue using: npm uninstall -g jest; npm install -g jest; npm cache clean; npm install.
Read more >
Error: Path must be a string. Received undefined - Forge
I could deploy previously. Now, this error occurs. What can be the problem ? Snapshot error occurred: Error: Path must be a string....
Read more >
cypress-plugin-snapshots - Bountysource
Run test and get it failed (due to toMatchImageSnapshot()) ... an automatically generated test file and I need to customize the snapshot path...
Read more >
How to use the jest-snapshot.SnapshotState function in ... - Snyk
To help you get started, we've selected a few jest-snapshot. ... new SnapshotState(undefined, { snapshotPath: EXISTING_SNAPSHOT_PATH, updateSnapshot: "all", }); ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found