Skip to content

Coverage isn't calculated properly for non-SFC #244

Open
@dmytrokirpa

Description

@dmytrokirpa

Version

3.0.5

Reproduction link

https://github.com/dmitriykirpa/vue-cli-jest-coverage-example

Environment info

  System:
    OS: macOS 10.15.4
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  Binaries:
    Node: 14.2.0 - /usr/local/bin/node
    Yarn: 1.21.0 - /usr/local/bin/yarn
    npm: 6.14.4 - /usr/local/bin/npm
  Browsers:
    Chrome: 81.0.4044.138
    Firefox: 70.0.1
    Safari: 13.1
  npmPackages:
    @vue/cli-overlay:  4.3.1 
    @vue/cli-plugin-eslint: ^4.3.0 => 4.3.1 
    @vue/cli-plugin-router:  4.3.1 
    @vue/cli-plugin-unit-jest: ^4.3.0 => 4.3.1 
    @vue/cli-plugin-vuex:  4.3.1 
    @vue/cli-service: ^4.3.0 => 4.3.1 
    @vue/cli-shared-utils:  4.3.1 
    @vue/component-compiler-utils:  3.1.2 
    @vue/eslint-config-prettier: ^6.0.0 => 6.0.0 
    @vue/preload-webpack-plugin:  1.1.1 
    @vue/test-utils: 1.0.0-beta.31 => 1.0.0-beta.31 
    @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.11 => 2.6.11 
    vue-eslint-parser:  7.1.0 
    vue-hot-reload-api:  2.3.4 
    vue-jest:  3.0.5 
    vue-loader:  15.9.2 
    vue-style-loader:  4.1.2 
    vue-template-compiler: ^2.6.11 => 2.6.11 
    vue-template-es2015-compiler:  1.9.1 
  npmGlobalPackages:
    @vue/cli: Not Found

Steps to reproduce

  1. Create a new vue-cli project (or configure it manually) with vue-jest configured.
  2. Move the script section from the src/components/HelloWorld.vue to a separate file script.js.
  3. Add the <script src="./script.js" /> to src/components/HelloWorld.vue
  4. Run yarn/npm run test:unit --coverage
  5. Observe the result.

What is expected?

Coverage for script.js calculated properly

What is actually happening?

Coverage for script.js is 0

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions