-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Reference error: performance is not defined when running unit tests (mocha) #9717
Description
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