Skip to content

Threshold on a Glob Pattern does not show an error message #5545

@kanteankit

Description

@kanteankit

Describe the bug

When a global coverage threshold is set in vitest configuration, an error message is shown like this

ERROR: Coverage for functions (0%) does not meet global threshold (100%)

image

But, when threshold for a particular file is set using the glob-pattern option, there is no such error message.

Reproduction

1.Clone this repo: https://github.com/kanteankit/vitest
2. Run npm install
3. Run npm run coverage

Expected behaviour: An error message should show up which says that the threshold for the file AsAsync.vue is not met.
Actual behaviour: There is no error message

In vitest.config.ts, a threshold of 100 is set on components/AsAsync.vue. But, it is not throwing any error.

/// <reference types="vitest" />

import { defineConfig } from 'vite'
import Vue from '@vitejs/plugin-vue'

export default defineConfig({
  plugins: [
    Vue(),
  ],
  test: {
    globals: true,
    environment: 'jsdom',
    coverage: {
      thresholds: {
        // functions: 100, // This shows an error message
        'components/AsAsync.vue': {
          functions: 100 // This does not show an error message
        }
      }
    }
  },
})

Note: Couldn't provide a Stackblitz because it gives an error saying @vitest/coverage-v8 does not work on Stackblitz. Report will be empty.

System Info

System:
    OS: Linux 5.19 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 5.60 GB / 15.48 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 20.9.0 - ~/.nvm/versions/node/v20.9.0/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 10.2.5 - ~/.nvm/versions/node/v20.9.0/bin/npm
  Browsers:
    Chrome: 123.0.6312.122
  npmPackages:
    @vitejs/plugin-vue: latest => 5.0.4 
    @vitest/coverage-istanbul: ^1.5.0 => 1.5.0 
    @vitest/coverage-v8: ^1.5.0 => 1.5.0 
    vite: latest => 5.2.8 
    vitest: latest => 1.5.0

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: coverageIssues and PRs related to the coverage featurep2-edge-caseBug, but has workaround or limited in scope (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions