toMatchImageSnapshot fails with Path must be a string. Received undefined
See original GitHub issueWe 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:
- Created 4 years ago
- Reactions:4
- Comments:7 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
thanks @meinaart - can confirm this release has fixed this issue 😃
Thanks @johnmcclumpha