7

I have VueJS application written with NuxtJS. This setup causes that I have many files index.vue in different directories. When I run the testing suite with commend jest --no-cache --watch --coverage only 1 file index.vue has being picked up by coverage results.

my configuration of jest in package.json is:

"jest": {
    "transform": {
      "^.+.vue$": "vue-jest",
      "^.+.js$": "babel-jest"
    },
    "collectCoverage": true,
    "collectCoverageFrom": [
      "**/*.{js,vue}",
      "!**/node_modules/**"
    ],
    "coverageReporters": [
      "text"
    ],
    "setupTestFrameworkScriptFile": "jest-extended"
}

and results show only coverage for 1 index.vue file (even I have multiple of them as well other .vue files).

What configuration option I need to add to run coverage for all .vue files?

1
  • 1
    Could you show coverage table and folder structure? Commented Jan 15, 2019 at 14:23

1 Answer 1

4
+200

At a first sight, I would expect to see Jest's moduleFileExtensions config option in place like:

 "jest": {
    "moduleFileExtensions": ["js", "json", "jsx", "node", "vue"],
    // The rest of your config...
  }

The option tells Jest which file extensions are used by the modules of your application.

Sign up to request clarification or add additional context in comments.

2 Comments

This unfortunately didn't work for me. Only index.vue is getting coverage and I have the exact same config.
Fixed this by exporting the Vue instance in the script section of the Vue files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.