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.

PrettyFormatPluginError: object is not a function

See original GitHub issue

🐛 Bug Report

The code below makes Jest crash internally with PrettyFormatPluginError: object is not a function error

To Reproduce

Steps to reproduce the behavior:

  1. Create ./src/index.js with code
'use strict'

module.exports = rec

function rec (p) {
  return new Proxy(p, {
    get: (obj, prop) => {
      return rec(obj)
    }
  })
}
  1. Create ./test/index.test.js with code
'use strict'

const rec = require('../src')

test('', () => {
  const inner = 'inner'
  const outer = rec({inner})

  expect(outer.inner).toEqual('inner')
})
  1. Run Jest
 FAIL  test/index.test.js
  ×  (9ms)

  ● 

    PrettyFormatPluginError: object is not a functionTypeError: object is not a function
        at RegExp.test (<anonymous>)

       7 |   const outer = rec({inner})
       8 | 
    >  9 |   expect(outer.inner).toEqual('inner')
         |                       ^
      10 | })

      at testName (node_modules/pretty-format/build/plugins/DOMCollection.js:47:53)
      at Object.toEqual (test/index.test.js:9:23)

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

Link to repl or repo (highly encouraged)

https://github.com/Alexsey/jest-bug-rec

Expected behavior

There should be a message on the actual error (if there is any)

envinfo

npx: installed 1 in 2.175s

  System:
    OS: Windows 10
    CPU: (4) x64 Intel(R) Core(TM) i5-6600 CPU @ 3.30GHz
  Binaries:
    Node: 12.10.0 - C:\Program Files\nodejs\node.EXE
    npm: 6.11.3 - C:\Program Files\nodejs\npm.CMD
  npmPackages:
    jest: ^24.9.0 => 24.9.0

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:4
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
hiahmedhameedcommented, Nov 2, 2020

I think i have the same error

AppPromotion › matches snapshot

    PrettyFormatPluginError: undefined:1:846: property missing ':'Error: undefined:1:846: property missing ':'

      61 |     );
      62 |
    > 63 |     expect(container).toMatchSnapshot();
         |                       ^
      64 |   });
      65 |
      66 |   describe('user agent', () => {
[...]

"jest-styled-components": "^7.0.3",
"@testing-library/react": "^9.3.2",
"jest": "24.9.0"

[...]

Any idea ?

0reactions
github-actions[bot]commented, Jun 29, 2022

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Function: TypeError: Object(...) is not a function
I am having some issues updating my team's code in order to app the inactivity function. But when trying to do ...
Read more >
Object.prototype.hasOwnProperty() - JavaScript | MDN
The method returns false if the property is inherited, or has not been declared at all. Unlike the in operator, this method does...
Read more >
TypeError: Object(...) is not a function : r/reactjs - Reddit
TypeError: Object(...) is not a function. Hello,. While working in React I made an ES6 arrow function. When I saved my work and...
Read more >
JavaScript: Uncaught TypeError: n is not a function
This means that the expression did not return a function object. So you need to understand that what you are trying to achieve...
Read more >
How to Handle JavaScript Uncaught TypeError: “x” is Not a ...
The Javascript TypeError: "x" is not a function occurs when calling a function on a value or object, which is not actually a...
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