vuejs / vue-cli

🛠️ webpack-based tooling for Vue.js Development
https://cli.vuejs.org/
MIT License
29.76k stars 6.33k forks source link

Failed test:unit build exits with code 0 #6739

Open blimmer opened 3 years ago

blimmer commented 3 years ago

Version

5.0.0-beta.5

Reproduction link

github.com

Environment info

Environment Info:

  System:
    OS: macOS 11.6
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  Binaries:
    Node: 14.18.0 - ~/.nvm/versions/node/v14.18.0/bin/node
    Yarn: 1.22.11 - /usr/local/bin/yarn
    npm: 6.14.15 - ~/.nvm/versions/node/v14.18.0/bin/npm
  Browsers:
    Chrome: 94.0.4606.61
    Edge: 94.0.992.38
    Firefox: 94.0
    Safari: 15.0
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.2.1
    @vue/babel-helper-vue-transform-on:  1.0.2
    @vue/babel-plugin-jsx:  1.1.0
    @vue/babel-plugin-transform-vue-jsx:  1.2.1
    @vue/babel-preset-app:  5.0.0-beta.5
    @vue/babel-preset-jsx:  1.2.4
    @vue/babel-sugar-composition-api-inject-h:  1.2.1
    @vue/babel-sugar-composition-api-render-instance:  1.2.4
    @vue/babel-sugar-functional-vue:  1.2.2
    @vue/babel-sugar-inject-h:  1.2.2
    @vue/babel-sugar-v-model:  1.2.3
    @vue/babel-sugar-v-on:  1.2.3
    @vue/cli-overlay:  5.0.0-beta.5
    @vue/cli-plugin-babel: ^5.0.0-beta.5 => 5.0.0-beta.5
    @vue/cli-plugin-eslint: ^5.0.0-beta.5 => 5.0.0-beta.5
    @vue/cli-plugin-router: ^5.0.0-beta.5 => 5.0.0-beta.5
    @vue/cli-plugin-typescript: ^5.0.0-beta.5 => 5.0.0-beta.5
    @vue/cli-plugin-unit-mocha: ^5.0.0-beta.5 => 5.0.0-beta.5
    @vue/cli-plugin-vuex: ^5.0.0-beta.5 => 5.0.0-beta.5
    @vue/cli-service: ^5.0.0-beta.5 => 5.0.0-beta.5
    @vue/cli-shared-utils:  5.0.0-beta.5
    @vue/component-compiler-utils:  3.2.2
    @vue/eslint-config-typescript: ^7.0.0 => 7.0.0
    @vue/test-utils: ^1.0.3 => 1.2.2
    @vue/web-component-wrapper:  1.3.0
    eslint-plugin-vue: ^7.6.0 => 7.19.1
    typescript: ~4.1.5 => 4.1.6
    vue: ^2.6.11 => 2.6.14
    vue-class-component: ^7.2.3 => 7.2.6
    vue-eslint-parser:  7.11.0
    vue-hot-reload-api:  2.3.4
    vue-loader:  16.8.1 (15.9.8)
    vue-property-decorator: ^9.1.2 => 9.1.2
    vue-router: ^3.2.0 => 3.5.2
    vue-style-loader:  4.1.3
    vue-template-compiler: ^2.6.11 => 2.6.14
    vue-template-es2015-compiler:  1.9.1
    vuex: ^3.4.0 => 3.6.2
  npmGlobalPackages:
    @vue/cli: Not Found

Steps to reproduce

  1. Clone the code (https://github.com/blimmer/example-vue-app.git)
  2. Check out the failing branch (git checkout failed-build-zero-exit-code)
  3. Install dependencies via npm ci
  4. Run vue-cli-service test:unit

What is expected?

The test suite does not run because of an invalid configuration in vue.config.js. I expect the vue-cli-service test:unit process to exit with a non-zero exit code, so I'm aware of the issue in my CI platform.

What is actually happening?

The test suite fails and does not run, but the command completes with a zero exit code.

 9:16:41  ~/code/example-vue-app   failed-build-zero-exit-code  vue-cli-service test:unit
(node:30966) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'cacheGroups' of undefined
    at configureWebpack (/Users/blimmer/code/example-vue-app/vue.config.js:7:44)
    at /Users/blimmer/code/example-vue-app/node_modules/@vue/cli-service/lib/Service.js:267:21
    at Array.forEach (<anonymous>)
    at Service.resolveWebpackConfig (/Users/blimmer/code/example-vue-app/node_modules/@vue/cli-service/lib/Service.js:264:30)
    at Object.<anonymous> (/Users/blimmer/code/example-vue-app/node_modules/@vue/cli-service/webpack.config.js:12:26)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at findConfig (/Users/blimmer/code/example-vue-app/node_modules/mochapack/lib/cli/argsParser/optionsFromParsedArgs/webpack/requireWebpackConfig.js:139:18)
    at /Users/blimmer/code/example-vue-app/node_modules/mochapack/lib/cli/argsParser/optionsFromParsedArgs/webpack/requireWebpackConfig.js:153:31
    at step (/Users/blimmer/code/example-vue-app/node_modules/mochapack/lib/cli/argsParser/optionsFromParsedArgs/webpack/requireWebpackConfig.js:33:23)
    at Object.next (/Users/blimmer/code/example-vue-app/node_modules/mochapack/lib/cli/argsParser/optionsFromParsedArgs/webpack/requireWebpackConfig.js:14:53)
    at /Users/blimmer/code/example-vue-app/node_modules/mochapack/lib/cli/argsParser/optionsFromParsedArgs/webpack/requireWebpackConfig.js:8:71
(Use `node --trace-warnings ...` to show where the warning was created)
(node:30966) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:30966) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
 9:16:45  ~/code/example-vue-app   failed-build-zero-exit-code  echo $?
0

This happens with the latest stable Vue-CLI (4.5.13), as well as the lastest v5 version.

aumann commented 3 years ago

I've just noticed that we had the same issue and our CI tests had not been running :sweat_smile:

Do you maybe know of a workaround or a way to set this --unhandled-rejections=strict flag?

blimmer commented 3 years ago

@aumann I didn't find a workaround, but also didn't spend too much time looking into it. With a bit of digging, you might be able to find the code that needs updated and use patch-package to update it locally.

aumann commented 3 years ago

Thank you very much for your fast response.

Yeah, the actual fix for the underlying problem has been trivial in our case. I'm mostly worried about future, similar issues causing silent CI fails...