Skip to content

Improve the message when run coverage while there are no tests #6141

@tiendq

Description

@tiendq

🐛 Bug Report

When you run jest with --coverage but there are no tests, it shows error "Jest: Coverage data for global was not found."

To Reproduce

  1. Delete all test files e.g. *.test.js

  2. Run jest --config=jest.json --coverage with below configuration in jest.json:

{
  "testEnvironment": "node",
  "coverageThreshold": {
    "global": {
      "branches": 90,
      "functions": 90,
      "lines": 90,
      "statements": -10
    }
  },
  "collectCoverageFrom" : [
    "*.js"
  ]
}

Expected behavior

A simple and clear error like "No tests found", or simply skipping coverage, or coverage report as usual (and failed 100%).

Link to repl or repo (highly encouraged)

https://github.com/Tiendq/lego-part-loader

Run npx envinfo --preset jest

System:
    OS: macOS Sierra 10.12.6
  Binaries:
    Node: 10.0.0 - /usr/local/bin/node
    Yarn: 1.6.0 - /usr/local/bin/yarn
    npm: 5.6.0 - /usr/local/bin/npm
  npmPackages:
    jest: ^22.4.3 => 22.4.3 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions