Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Performance.mark is not a function #1308

Closed
reyraa opened this issue Oct 27, 2017 · 10 comments
Closed

Error: Performance.mark is not a function #1308

reyraa opened this issue Oct 27, 2017 · 10 comments

Comments

@reyraa
Copy link

reyraa commented Oct 27, 2017

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.

@ljharb
Copy link
Member

ljharb commented Oct 27, 2017

I would recommend not migrating two things at once. Get react 15 and enzyme 3 working first; then upgrade to react 16.

@reyraa
Copy link
Author

reyraa commented Oct 27, 2017

@ljharb I've migrated react first, application is working without any issues. the migration was smooth and easy. all of my e2e tests pass just fine. the only problem is with enzyme throwing this error

@ljharb
Copy link
Member

ljharb commented Oct 27, 2017

Right, but if you don't have enzyme 3 passing on react 15 first, then we can't know if it's react 16 breaking things (which might be expected), or if it's enzyme 3 breaking things.

@ljharb
Copy link
Member

ljharb commented Oct 27, 2017

Unit tests passing are much more important than e2e tests anyways.

@oliviertassinari
Copy link

oliviertassinari commented Oct 28, 2017

I'm subscribing to this thread as having a similar issue. I haven't figured out how such error is even possible given the defensive check React is using: https://github.com/facebook/react/blob/v16.0.0/src/renderers/shared/fiber/ReactDebugFiberPerf.js#L42.

@oliviertassinari
Copy link

oliviertassinari commented Oct 28, 2017

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

@oliviertassinari
Copy link

I think that we can close this issue. Here is another one: sinonjs/fake-timers#136.

@ljharb
Copy link
Member

ljharb commented Oct 29, 2017

@reyraa are you also using sinon and useFakeTimers?

@reyraa
Copy link
Author

reyraa commented 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

@ljharb ljharb closed this as completed Oct 30, 2017
@remojansen
Copy link

Here is a workaround that worked for me sinonjs/fake-timers#136 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants