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
Closed

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

zdravkov opened this issue Mar 14, 2019 · 12 comments

Comments

@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
Copy link
Member

posva commented Mar 14, 2019

Please provide a repro when reporting bugs

@posva posva closed this as completed Mar 14, 2019
@zdravkov
Copy link
Author

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

@pauldps
Copy link

pauldps 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
Copy link
Member

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.

@posva
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
Copy link
Member

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 😂

@dereli
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
Copy link

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
Copy link

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

Same question. Where do I add the following lines?

@vuew-wp
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 pushed a commit to rei/vunit that referenced this issue Mar 6, 2020
- Updating expect to chai.expect.
- Removing workaround for vuejs/vue#9698
- Minor logging refactor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants