vuejs / vue-cli

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

adding @vue/cli-plugin-unit-jest breaks #4073

Closed slushnys closed 5 years ago

slushnys commented 5 years ago

Version

3.7.0

Environment info

System:
    OS: macOS 10.14.4
    CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
  Binaries:
    Node: 11.15.0 - /usr/local/bin/node
    Yarn: Not Found
    npm: 6.9.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 74.0.3729.169
    Firefox: Not Found
    Safari: 12.1
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0-beta.3 
    @vue/babel-plugin-transform-vue-jsx:  1.0.0-beta.3 
    @vue/babel-preset-app:  3.7.0 
    @vue/babel-preset-jsx:  1.0.0-beta.3 
    @vue/babel-sugar-functional-vue:  1.0.0-beta.3 
    @vue/babel-sugar-inject-h:  1.0.0-beta.3 
    @vue/babel-sugar-v-model:  1.0.0-beta.3 
    @vue/babel-sugar-v-on:  1.0.0-beta.3 
    @vue/cli-overlay:  3.7.0 
    @vue/cli-plugin-babel: ^3.7.0 => 3.7.0 
    @vue/cli-plugin-eslint: ^3.7.0 => 3.7.0 
    @vue/cli-plugin-typescript: ^3.7.0 => 3.7.0 
    @vue/cli-plugin-unit-jest: ^3.8.0 => 3.8.0 
    @vue/cli-service: ^3.7.0 => 3.7.0 
    @vue/cli-shared-utils:  3.7.0 (3.8.0)
    @vue/component-compiler-utils:  2.6.0 
    @vue/eslint-config-prettier: ^4.0.1 => 4.0.1 
    @vue/eslint-config-typescript: ^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-config-vuetify: ^0.2.0 => 0.2.0 
    eslint-plugin-vue: ^5.0.0 => 5.2.2 (4.7.1)
    jest-serializer-vue:  2.0.2 
    typescript: ^3.4.3 => 3.4.5 
    vue: ^2.6.10 => 2.6.10 
    vue-class-component: ^7.1.0 => 7.1.0 
    vue-eslint-parser:  2.0.3 (5.0.0)
    vue-hot-reload-api:  2.3.3 
    vue-jest:  3.0.4 
    vue-loader:  15.7.0 
    vue-property-decorator: ^8.1.1 => 8.1.1 
    vue-rollbar: ^1.0.0 => 1.0.0 
    vue-router: ^3.0.3 => 3.0.6 
    vue-style-loader:  4.1.2 
    vue-template-compiler: ^2.5.21 => 2.6.10 
    vue-template-es2015-compiler:  1.9.1 
    vuedraggable: ^2.20.0 => 2.20.0 
    vuetify: ^1.5.14 => 1.5.14 
    vuex: ^3.1.1 => 3.1.1 
  npmGlobalPackages:
    @vue/cli: 3.7.0

Steps to reproduce

try adding @vue/cli-plugin-unit-jest: vue add @vue/cli-plugin-unit-jest

What is expected?

plugin installed and working

What is actually happening?

Plugin breaks with error message and jest doesnt work, transforming not possible.

No prompts found for @vue/cli-plugin-unit-jest WARN conflicting versions for project dependency "@vue/test-utils":

Using newer version (1.0.0-beta.29), but this may cause build errors. ERROR SyntaxError: Unexpected token / in JSON at position 75 SyntaxError: Unexpected token / in JSON at position 75 at JSON.parse () at api.render.files (/Users/slusnys/Workspace/equinnolab/portal/link/node_modules/@vue/cli-plugin-unit-jest/generator/index.js:118:29) at Generator.resolveFiles (/usr/local/lib/node_modules/@vue/cli/lib/Generator.js:209:13) at processTicksAndRejections (internal/process/task_queues.js:86:5) { Error: Command failed: vue invoke @vue/cli-plugin-unit-jest --$inlineOptions {}

🚀 Invoking generator for @vue/cli-plugin-unit-jest...

at makeError (/usr/local/lib/node_modules/@vue/cli/node_modules/execa/index.js:174:9)
at Promise.all.then.arr (/usr/local/lib/node_modules/@vue/cli/node_modules/execa/index.js:278:16)
at processTicksAndRejections (internal/process/task_queues.js:86:5)

code: 1, stdout: '\n🚀 Invoking generator for @vue/cli-plugin-unit-jest...\n', stderr: null, failed: true, signal: null, cmd: 'vue invoke @vue/cli-plugin-unit-jest --$inlineOptions {}', timedOut: false, killed: false }

haoqunjiang commented 5 years ago

Seems you have a corrupted tsconfig.json file. Could you please provide a reproduction repo?

slushnys commented 5 years ago

I can't provide you with . a repo . currently, I . can however share . the tsconfig.json file with you:

{
  "compilerOptions": {
    "outDir": "dist",
    "target": "esnext",
    "module": "esnext",
    "strict": true,
    "jsx": "preserve",
    "importHelpers": true,
    "moduleResolution": "node",
    "esModuleInterop": true,
    "allowJs": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "baseUrl": ".",
    "types": [
      "webpack-env"
    ],
    "paths": {
      "@/*": [
        "src/*"
      ]
    },
    "lib": [
      "esnext",
      "dom",
      "dom.iterable",
      "scripthost"
    ]
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.tsx",
    "src/**/*.js",
    "src/**/*.vue",
    "tests/**/*.ts",
    "tests/**/*.tsx"
  ],
  "exclude": [
    "node_modules",
    "dist"
  ]
}

I upgraded my vue-cli to 3.8.2 and it works as expected now. The problem is with 3.7.0 version i would say.

haoqunjiang commented 5 years ago

Then I'm closing this issue.

But that's still weird, @vue/cli-plugin-unit-jest didn't get any new feature or bugfixes in the 3.8 release https://github.com/vuejs/vue-cli/commits/v3/packages/%40vue/cli-plugin-unit-jest

suedar commented 4 years ago

Hey, did you find a way to fix it?

reech commented 4 years ago

@suedar I had the same problem when vue add @vue/cli-plugin-unit-jest, and it seems as @sodatea mentioned that I had a broken tsconfig.json. In my case due to a trailing/extra comma. As soon as I removed that it worked:

  "include": [
    "src/**/*.ts",
    "src/**/*.vue",
    "tests/**/*.ts", //<-- remove this
  ]
qiuyaofan commented 3 years ago

tsconfig.json格式有问题就会,多了个逗号 http://www.kjson.com/jsoneditor/ 看json格式有没有问题可以在在线网站格式化测试下

hybridwebdev commented 1 year ago

vue add @vue/cli-plugin-unit-jest

This one just bit me in

@suedar I had the same problem when vue add @vue/cli-plugin-unit-jest, and it seems as @sodatea mentioned that I had a broken tsconfig.json. In my case due to a trailing/extra comma. As soon as I removed that it worked:

  "include": [
    "src/**/*.ts",
    "src/**/*.vue",
    "tests/**/*.ts", //<-- remove this
  ]

This one just bit me in the ass for an hour. Found your comment on google and it helped me.