Skip to content

vue cli4 cannot be configured according to karma, but cli3 can succeed #5525

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

Closed
changhe-fu opened this issue May 26, 2020 · 4 comments
Closed
Labels
needs team repro We acknowledged your report and will soon try to reproduce it

Comments

@changhe-fu
Copy link

changhe-fu commented May 26, 2020

Version

4.1.2

Reproduction link

https://github.com/heyi-let/vue-cli4_unit_karma

Environment info

System:
OS: macOS Mojave 10.14.5
CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
Binaries:
Node: 11.14.0 - ~/.nvm/versions/node/v11.14.0/bin/node
Yarn: Not Found
npm: 6.7.0 - ~/.nvm/versions/node/v11.14.0/bin/npm
Browsers:
Chrome: 81.0.4044.138
Firefox: 71.0
Safari: 12.1.1
npmPackages:
@vue/babel-helper-vue-jsx-merge-props: 1.0.0
@vue/babel-plugin-transform-vue-jsx: 1.1.2
@vue/babel-preset-app: 4.4.1
@vue/babel-preset-jsx: 1.1.2
@vue/babel-sugar-functional-vue: 1.1.2
@vue/babel-sugar-inject-h: 1.1.2
@vue/babel-sugar-v-model: 1.1.2
@vue/babel-sugar-v-on: 1.1.2
@vue/cli-overlay: 4.4.1
@vue/cli-plugin-babel: ^4.4.0 => 4.4.1
@vue/cli-plugin-e2e-cypress: ^4.4.0 => 4.4.1
@vue/cli-plugin-eslint: ^4.4.0 => 4.4.1
@vue/cli-plugin-router: ^4.4.0 => 4.4.1
@vue/cli-plugin-unit-mocha: ^4.4.0 => 4.4.1
@vue/cli-plugin-vuex: ^4.4.0 => 4.4.1
@vue/cli-service: ^4.4.0 => 4.4.1
@vue/cli-shared-utils: 4.4.1
@vue/component-compiler-utils: 3.1.2
@vue/eslint-config-standard: ^5.1.2 => 5.1.2
@vue/preload-webpack-plugin: 1.1.1
@vue/test-utils: ^1.0.3 => 1.0.3
@vue/web-component-wrapper: 1.2.0
eslint-plugin-vue: ^6.2.2 => 6.2.2
vue: ^2.6.11 => 2.6.11
vue-eslint-parser: 7.1.0
vue-hot-reload-api: 2.3.4
vue-loader: 15.9.2
vue-router: ^3.2.0 => 3.2.0
vue-style-loader: 4.1.2
vue-template-compiler: ^2.6.11 => 2.6.11
vue-template-es2015-compiler: 1.9.1
vuex: ^3.4.0 => 3.4.0
npmGlobalPackages:
@vue/cli: 4.1.2

Steps to reproduce

git clone https://github.com/heyi-let/vue-cli4_unit_karma

The test:unit can be executed successfully in the cli-service4 branch.

git checkout cli-service3

npm install

npm run test:unit

But will fail in the cli-service4 branch

git checkout cli-service4

npm install

npm run test:unit

They have different @vue/cli-service versions,everything else is the same.

What is expected?

Can successfully run when using cli4

What is actually happening?

failed

@haoqunjiang
Copy link
Member

Thanks for submitting this issue. Due to our limited time, we have to ask you to include a reproduction link to a minimal full reproduction of your problem (for example in a GitHub repository) so we can find what is causing the issue. Thank you for your understanding.

@haoqunjiang haoqunjiang added the needs reproduction This issue is missing a minimal runnable reproduction, provided by the author label May 26, 2020
@changhe-fu
Copy link
Author

already added

@haoqunjiang haoqunjiang added needs team repro We acknowledged your report and will soon try to reproduce it and removed needs reproduction This issue is missing a minimal runnable reproduction, provided by the author labels May 27, 2020
@haoqunjiang
Copy link
Member

Please add a NODE_ENV=test prefix to the test command.


The reason: dfe3987

Karma can't handle split chunks.

  • In @vue/cli-service v3, unless you explicitly set NODE_ENV to production, splitChunks won't be turned on.
  • In @vue/cli-service v4, unless you explicitly set NODE_ENV to test, splitChunks will be turned on by default.

It is a good practice to always set NODE_ENV to test during unit testing because many of the packages in Node.js ecosystem follows this convention.

Actually, with NODE_ENV=test, you can skip BABEL_ENV=test because it will default to NODE_ENV.

@changhe-fu
Copy link
Author

config worked for me.
thank you very much !

haoqunjiang added a commit to haoqunjiang/vue-test-utils that referenced this issue May 28, 2020
According to the [babel documentation](https://babeljs.io/docs/en/options#envname),
`NODE_ENV` can also be recognized when loading configurations, and
`NODE_ENV` has better interoperability in the ecosystem.

Here's a use case that `NODE_ENV` works well while `BABEL_ENV` might
cause confusion: vuejs/vue-cli#5525 (comment)
lmiller1990 pushed a commit to vuejs/vue-test-utils that referenced this issue May 28, 2020
According to the [babel documentation](https://babeljs.io/docs/en/options#envname),
`NODE_ENV` can also be recognized when loading configurations, and
`NODE_ENV` has better interoperability in the ecosystem.

Here's a use case that `NODE_ENV` works well while `BABEL_ENV` might
cause confusion: vuejs/vue-cli#5525 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs team repro We acknowledged your report and will soon try to reproduce it
Projects
None yet
Development

No branches or pull requests

2 participants