Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jest test coverage for VueJS application with Nuxt

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?

like image 364
bensiu Avatar asked Jan 10 '19 02:01

bensiu


1 Answers

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.

like image 187
Andrea Carraro Avatar answered Oct 09 '22 09:10

Andrea Carraro