vuejs / vue-cli

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

Vue cli doesn't read Jest config file #6352

Open pooria-h opened 3 years ago

pooria-h commented 3 years ago

Version

4.5.4

Environment info

System:
    OS: macOS 11.0.1
    CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
  Binaries:
    Node: 14.15.0 - ~/.nvm/versions/node/v14.15.0/bin/node
    Yarn: Not Found
    npm: 6.14.8 - ~/.nvm/versions/node/v14.15.0/bin/npm
  Browsers:
    Chrome: 89.0.4389.82
    Edge: Not Found
    Firefox: 86.0
    Safari: 14.0.1
  npmPackages:
    @intlify/vue-i18n-loader: ^1.0.0 => 1.0.0
    @vue/babel-helper-vue-jsx-merge-props:  1.2.1
    @vue/babel-helper-vue-transform-on:  1.0.0-rc.2
    @vue/babel-plugin-jsx:  1.0.0-rc.3
    @vue/babel-plugin-transform-vue-jsx:  1.2.1
    @vue/babel-preset-app:  4.5.9
    @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:  4.5.9
    @vue/cli-plugin-babel: ~4.5.4 => 4.5.9
    @vue/cli-plugin-eslint: ~4.5.4 => 4.5.9
    @vue/cli-plugin-router: ~4.5.4 => 4.5.9
    @vue/cli-plugin-unit-jest: ^4.5.11 => 4.5.11
    @vue/cli-plugin-unit-mocha: ~4.5.4 => 4.5.9
    @vue/cli-plugin-vuex: ~4.5.4 => 4.5.9
    @vue/cli-service: ~4.5.4 => 4.5.9
    @vue/cli-shared-utils:  4.5.9 (4.5.11)
    @vue/component-compiler-utils:  3.2.0
    @vue/eslint-config-prettier: ^6.0.0 => 6.0.0
    @vue/preload-webpack-plugin:  1.1.2
    @vue/test-utils: ^1.1.2 => 1.1.2
    @vue/web-component-wrapper:  1.2.0
    eslint-plugin-vue: ^6.2.2 => 6.2.2
    jest-serializer-vue:  2.0.2
    vue: 2.6.12 => 2.6.12
    vue-cli-plugin-i18n: ^1.0.1 => 1.0.1
    vue-cli-plugin-vuetify: ^2.0.8 => 2.0.8
    vue-color: ^2.8.1 => 2.8.1
    vue-eslint-parser:  7.2.0
    vue-hot-reload-api:  2.3.4
    vue-i18n: 8.21.0 => 8.21.0
    vue-i18n-extract:  1.0.2
    vue-jest:  3.0.7
    vue-loader:  15.9.5 (16.1.0)
    vue-router: 3.4.3 => 3.4.3
    vue-style-loader:  4.1.2
    vue-template-compiler: ^2.6.12 => 2.6.12
    vue-template-es2015-compiler:  1.9.1
    vuejs-noty: 0.1.3 => 0.1.3
    vuetify: 2.3.21 => 2.3.21
    vuetify-loader: ^1.6.0 => 1.6.0
    vuex: 3.5.1 => 3.5.1
  npmGlobalPackages:
    @vue/cli: 4.5.9

Steps to reproduce

This is the command I'm running:

vue-cli-service test:unit

This is the content of jest.config.js:

module.exports = {
  preset: '@vue/cli-plugin-unit-jest',
  transform: {
    "^. \\.js$": "babel-jest",
    ". \\.(css||scss|png|jpg|ttf|woff|woff2|svg)$": "jest-transform-stub"
  }
}

The documentation says by default CLI reads this file but when I'm passing options in this file or removing its content completely, nothing happens. Also I've tried passing the options through package.json file but nothing happens.

"jest": {
    "transform": {
      "^. \\.js$": "babel-jest",
      ". \\.(css|scss|png|jpg|ttf|woff|woff2|svg)$": "jest-transform-stub"
    }
  },

What is expected?

To read the config file and an option that logs that this file is reading on the runtime.

What is actually happening?

Doesn't read the config file

haoqunjiang commented 3 years ago

Please provide a runnable reproduction. Code snippets are not enough for us to reproduce the issue.