Error: Performance.mark is not a function

See original GitHub issue

Hi,

What am I doing? I’m trying to migrate from react 15 to react 16, consequently migrate from enzyme v2.x to v3.x. I have about 500 unit tests in which I use enzyme to mount my component. I followed Migration Guide and faced this error in over 100 tests:

The error I hit:

FAILED TESTS:
  MyComponent
    ✖ title of my test
      HeadlessChrome 0.0.0 (Mac OS X 10.13.0)
    TypeError: performance.mark is not a function
        at beginMark (webpack:///node_modules/react-dom/cjs/react-dom.development.js:7406:0 <- src/tests.js:93987:17)
        at startWorkLoopTimer (webpack:///node_modules/react-dom/cjs/react-dom.development.js:7618:0 <- src/tests.js:94199:7)
        at performWork (webpack:///node_modules/react-dom/cjs/react-dom.development.js:12787:0 <- src/tests.js:99368:7)
        at batchedUpdates (webpack:///node_modules/react-dom/cjs/react-dom.development.js:13244:0 <- src/tests.js:99825:9)
        at performFiberBatchedUpdates (webpack:///node_modules/react-dom/cjs/react-dom.development.js:1646:0 <- src/tests.js:88227:10)
        at stackBatchedUpdates (webpack:///node_modules/react-dom/cjs/react-dom.development.js:1637:0 <- src/tests.js:88218:10)
        at batchedUpdates (webpack:///node_modules/react-dom/cjs/react-dom.development.js:1651:0 <- src/tests.js:88232:10)
        at Object.batchedUpdatesWithControlledComponents [as unstable_batchedUpdates] (webpack:///node_modules/react-dom/cjs/react-dom.development.js:1664:0 <- src/tests.js:88245:12)
        at webpack:///node_modules/react-dom/cjs/react-dom-test-utils.development.js:1216:0 <- src/tests.js:189114:14
        at Object.simulateEvent (webpack:///node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:250:0 <- src/tests.js:184077:15)

I’ve tried to fix the issue reducing the number of tests I run every time, it doesn’t seem to help.

Application specs: react: 16.0.0 react-dom: 16.0.0 Enzyme: 3.1.0 react-test-renderer: 16.0.0 Any help would be appreciated.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
oliviertassinaricommented, Oct 28, 2017

Ok, I have found the root cause. It’s coming from the usage of useFakeTimers() from sinon.

1reaction
reyraacommented, Oct 30, 2017

@ljharb Yes we’re using fake timers in multiple tests. and @oliviertassinari yes the problem stemmes in our sinon. useFakeTimers usages. thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js - performance.now is not a function - Stack Overflow
The perf_hooks module exports several things, one of them is performance , so using object destructuring you could do:
Read more >
performance.mark() - Web APIs - MDN Web Docs
The mark() method creates a named PerformanceMark object representing a high resolution timestamp marker in the browser's performance timeline.
Read more >
undefined is not a function (evaluating 'performance.mark ...
However it's defined in the startup module. There is no way it can't run. And there is no error for performance.mark('mwLoadStart');, only for...
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 >
TypeError: global.performance.now is not a function
TypeError: global.performance.now is not a function ; 1. make change to this file: node_modules/react-native-reanimated/src/reanimated2/core.ts Line 386, remove ...
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