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

Reference error: performance is not defined when running unit tests (mocha) #9717

Closed
Cameron637 opened this issue Mar 15, 2019 · 1 comment
Closed

Comments

@Cameron637
Copy link

Cameron637 commented Mar 15, 2019

Version

2.6.8

Reproduction link

https://github.com/Cameron637/vue-runtime-error-reproduction

Environment info


Environment Info:

  System:
    OS: macOS 10.14.3
    CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
  Binaries:
    Node: 10.15.2 - ~/.nvm/versions/node/v10.15.2/bin/node
    Yarn: Not Found
    npm: 6.9.0 - ~/.nvm/versions/node/v10.15.2/bin/npm
  Browsers:
    Chrome: 72.0.3626.121
    Firefox: 59.0.2
    Safari: 12.0.3
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0-beta.2 
    @vue/babel-plugin-transform-vue-jsx:  1.0.0-beta.2 
    @vue/babel-preset-app:  3.5.1 
    @vue/babel-preset-jsx:  1.0.0-beta.2 
    @vue/babel-sugar-functional-vue:  1.0.0-beta.2 
    @vue/babel-sugar-inject-h:  1.0.0-beta.2 
    @vue/babel-sugar-v-model:  1.0.0-beta.2 
    @vue/babel-sugar-v-on:  1.0.0-beta.2 
    @vue/cli-overlay:  3.5.1 
    @vue/cli-plugin-babel: ^3.5.0 => 3.5.1 
    @vue/cli-plugin-eslint: ^3.5.0 => 3.5.1 
    @vue/cli-plugin-unit-mocha: ^3.5.0 => 3.5.1 
    @vue/cli-service: ^3.5.0 => 3.5.1 
    @vue/cli-shared-utils:  3.5.1 
    @vue/component-compiler-utils:  2.6.0 
    @vue/eslint-config-airbnb: ^4.0.0 => 4.0.0 
    @vue/preload-webpack-plugin:  1.1.0 
    @vue/test-utils: 1.0.0-beta.29 => 1.0.0-beta.29 
    @vue/web-component-wrapper:  1.2.0 
    eslint-plugin-vue: ^5.0.0 => 5.2.2 
    vue: ^2.6.6 => 2.6.9 
    vue-eslint-parser:  2.0.3 
    vue-hot-reload-api:  2.3.3 
    vue-loader:  15.7.0 
    vue-style-loader:  4.1.2 
    vue-template-compiler: ^2.5.21 => 2.6.9 
    vue-template-es2015-compiler:  1.9.1 
  npmGlobalPackages:
    @vue/cli: 3.5.0

Steps to reproduce

Run npm install and then run npm run test:unit

What is expected?

This is a freshly created vue project with the vue-cli. Running the example unit test should pass successfully.

What is actually happening?

The unit test fails with a reference error from vue.runtime.esm.js.


This is happening because vue 2.6.9 (which is installed by npm by default even though it is ahead of the latest stable release) references the global performance attribute that should be available in the browser on line 4251 of vue.runtime.esm.js, but it is not available in the globals provided by jsdom-global. I've made a pull request to jsdom-global (here: rstacruz/jsdom-global#49) to fix its unavailability, but that repo doesn't seem to be actively maintained and it's doubtful that the fix will be merged anytime soon. It would probably be wise to use a different package or a fork of this one. If it helps, you're welcome to use my fork which already has the fix: https://github.com/Cameron637/jsdom-global

@posva
Copy link
Member

posva commented Mar 15, 2019

Duplicate of #9698

@posva posva marked this as a duplicate of #9698 Mar 15, 2019
@posva posva closed this as completed Mar 15, 2019
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

2 participants