Home > Mobile >  How can I know what percentage is covered by my tests?
How can I know what percentage is covered by my tests?

Time:02-08

I want to know how much of my project is covered by my tests, and I am currently trying to use jest to do so.

This is my jest.config.js:

module.exports = {
  verbose: true,
  preset: '@vue/cli-plugin-unit-jest',
  transform: {
    '^. \\.vue$': 'vue-jest',
  },
  jest: {
    coverageThreshold: {
      global: {
        branches: 50,
        functions: 50,
        lines: 50,
        statements: 50,
      },
      './src/components/': {
        branches: 40,
        statements: 40,
      },
      './src/reducers/**/*.js': {
        statements: 90,
      },
      './src/api/very-important-module.js': {
        branches: 100,
        functions: 100,
        lines: 100,
        statements: 100,
      },
    },
  },
}

But when I tried to run the command jest --coverage --coverageReporters="json-summary"

I get the error: bash: jest: command not found How do I solve this error?

my devDependecies are:

 "eslint-plugin-vue": "^7.0.0",
    "jest": "^27.5.0",
    "jest-cli": "^27.5.0",

CodePudding user response:

Your error is

bash: jest: command not found

Which means jest isn't added to your project/installed. Install it with: npm install --save-dev jest.

More information about jest

  •  Tags:  
  • Related