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.

[Cypress regression]`TypeError: data.hasOwnProperty is not a function`

See original GitHub issue

The problem

After adding line to cypress/support/index.js:

import '@percy/cypress';

then running Cypress fails with:

 Product Page
TypeError: data.hasOwnProperty is not a function
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:39:22)
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:40:32)
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:40:32)
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:40:32)
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:40:32)
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:40:32)
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:32:26)
    at Object.deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:16:17)
    at Encoder.encodeAsBinary (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/index.js:80:41)
    at Encoder.encode (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/index.js:42:29)
    at Client._packet (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io/dist/client.js:169:44)
    at Socket.packet (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io/dist/socket.js:160:21)
    at /Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io/dist/socket.js:274:18
    at /Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/lib/socket-base.js:318:28
    at tryCatcher (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:725:18)
    at _drainQueueStep (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (node:internal/timers:464:21)

TypeError: data.hasOwnProperty is not a function
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:39:22)
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:40:32)
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:40:32)
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:40:32)
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:40:32)
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:40:32)
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:32:26)
    at Object.deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:16:17)
    at Encoder.encodeAsBinary (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/index.js:80:41)
    at Encoder.encode (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/index.js:42:29)
    at Client._packet (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io/dist/client.js:169:44)
    at Socket.packet (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io/dist/socket.js:160:21)
    at /Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io/dist/socket.js:274:18
    at /Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/lib/socket-base.js:318:28
    at tryCatcher (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:725:18)
    at _drainQueueStep (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (node:internal/timers:464:21)

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

When I am downgrading cypress to:

    "cypress": "^8.7.0",

There is no error. Everything works properly.

Environment

  "devDependencies": {
    "cypress": "^9.1.0",
    "mocha": "^9.1.3",
    "mochawesome": "^7.0.1",
    "cypress-mochawesome-reporter": "^2.3.0",
    "cypress-multi-reporters": "^1.5.0",
    "mocha-junit-reporter": "^2.0.2",
    "typescript": "4.5.2",
    "@percy/cli": "^1.0.0-beta.70",
    "@percy/cypress": "^3.1.1"
  }
  • Node version: 16 LTS
  • MaxOS BigSur

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
cexbrayatcommented, Nov 24, 2021

@Robdel12 This appears to be related to percy: if I remove all the related code to percy, it works fine again in my case (on several projects). We do use TS as well, both TS 4.4 and TS 4.5.

0reactions
Robdel12commented, Dec 6, 2021

Upgrading to v9.1.1 of cypress should solve this https://github.com/cypress-io/cypress/issues/19091

Read more comments on GitHub >

github_iconTop Results From Across the Web

Possible regression in Cypress 9.1: `TypeError: data ... - GitHub
This suite runs successfully in Cypress 9.0. Here's the failure we get on almost all of the specs in our suite: TypeError: data.hasOwnProperty...
Read more >
hasOwnProperty is not a function in Node.js? - Stack Overflow
A way around the error is to call hasOwnProperty on Object explicitly, and bind it to the object, like so: // Calls "hasOwnProperty"...
Read more >
Changelog - Cypress Documentation
A TypeError displaying data.hasOwnProperty is not a function will no longer throw in some situations. Fixes #19091. Empty extra hooks will no longer...
Read more >
cypress 9.1.1 on Node.js NPM - NewReleases.io
New release cypress version 9.1.1 on Node.js NPM. ... A TypeError displaying data.hasOwnProperty is not a function will no longer throw in some...
Read more >
Object.prototype.hasOwnProperty() - JavaScript | MDN
The hasOwnProperty() method returns a boolean indicating whether the object has the specified property as its own property (as opposed to ...
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