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

Runtime exception: performance is not defined - with v2.6.9 #9698

Closed
zdravkov opened this Issue Mar 14, 2019 · 12 comments

Comments

Projects
None yet
8 participants
@zdravkov
Copy link

zdravkov commented Mar 14, 2019

Version

2.6.8

Reproduction link

https://jsfiddle.net/chrisvfritz/50wL7mdz/

Steps to reproduce

It is throwing from the vue/dist/vue.js file of the latest version I am currently trying to isolate it, yet it seems connected with the new code added recently. Will add more steps ASAP if you still don't observe it.

  1. replicated with this repo - https://github.com/vuejs/vue-test-utils-mocha-webpack-example
  2. clone it
  3. npm i
  4. npm test - no error
  5. npm update vue
  6. npm test - ReferenceError: performance is not defined

Greetings,
Plamen

What is expected?

no error observed

What is actually happening?

an error is observed

@posva

This comment has been minimized.

Copy link
Member

posva commented Mar 14, 2019

Please provide a repro when reporting bugs

@posva posva closed this Mar 14, 2019

@zdravkov

This comment has been minimized.

Copy link
Author

zdravkov commented Mar 14, 2019

Hi @posva,
The issue is not replicated with an online editor yet I have provided steps with a project from github under the Steps to reproduce section.
Greetings,
Plamen

@posva

This comment has been minimized.

Copy link
Member

posva commented Mar 14, 2019

The thing you linked to is an archived and deprecated example. A repro doesn't have to be jsfiddle, it can be an HTML file (or just the contents of it). It also shouldn't include other dependencies like mocha or vue-test-utils (it could be a problem on that package). Cheers.

@zdravkov

This comment has been minimized.

Copy link
Author

zdravkov commented Mar 14, 2019

Thanks for writing back!
Hm - I will try another approach - 'performance' that is at this line is not declared anywhere in the file. We have a window.performance and config.performance yet I don't see any global 'performance'. It came with the latest release because here is not present.

Once you run a static analyze on the file and it throws.

Greetings,
Plamen

@pauloddr

This comment has been minimized.

Copy link

pauloddr commented Mar 14, 2019

Also getting this. Got a warning from my CI after Vue got upgraded to 2.6.9 (I use Renovate to keep deps up to date).

@Justineo

This comment has been minimized.

Copy link
Member

Justineo commented Mar 14, 2019

It seems that in jsdom environment:

> window.performance
Performance {}
> performance
ReferenceError: performance is not defined

So we have to use window.performace instead of calling performance directly to make the code run correctly in jsdom.

@Justineo Justineo reopened this Mar 14, 2019

Justineo added a commit to Justineo/vue that referenced this issue Mar 14, 2019

@posva posva added the bug label Mar 14, 2019

@Justineo Justineo added the has PR label Mar 14, 2019

@posva posva added improvement has PR and removed has PR labels Mar 14, 2019

@posva

This comment has been minimized.

Copy link
Member

posva commented Mar 14, 2019

Okay, I think I opened the menu before you added the label improvement and clicked outside after you added the has PR label, so it removed it. Funny edge case

@Justineo

This comment has been minimized.

Copy link
Member

Justineo commented Mar 14, 2019

It should be noted that though JSDOM has a performance support via process.hrtime, I don't think we can guarantee current hack with performance will always work as expected in JSDOM environment (it's different from browsers' implementation after all).

@posva 😂

@yyx990803 yyx990803 closed this in 653c74e Mar 15, 2019

@dereli

This comment has been minimized.

Copy link

dereli commented Mar 15, 2019

Until this is released, a workaround is to add the following lines after JSDOM registration:

// eslint-disable-next-line no-undef
global.performance = window.performance;
@r3r00t3d

This comment has been minimized.

Copy link

r3r00t3d commented Mar 19, 2019

Until this is released, a workaround is to add the following lines after JSDOM registration:

// eslint-disable-next-line no-undef
global.performance = window.performance;

Sorry for being stupid but where do I add the following line since JSDOM registration is abstracted away in Vue CLI 3 and cli-plugin-unit-mocha (no setup.js)?

Thanks for the help...

@theonlychase

This comment has been minimized.

Copy link

theonlychase commented Mar 19, 2019

// eslint-disable-next-line no-undef 
global.performance = window.performance;

Same question. Where do I add the following lines?

@vuew-wp

This comment has been minimized.

Copy link

vuew-wp commented Mar 19, 2019

@theonlychase I placed it in my main test entry point test/setup.js it the same directory that contains your require('jsdom-global')

Referenced below at --require flag.

"test": "mocha-webpack --webpack-config webpack/webpack.config.test.js --require test/setup.js reporter mocha-bamboo-reporter"

peripateticus added a commit to rei/vunit that referenced this issue Mar 20, 2019

Fixing reported issue between vue and jsdom
- Setting global.performance to window.performance.
- See vuejs/vue#9698
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.