Skip to content

False negative with typecheck enabled #6151

@mmkal

Description

@mmkal

Describe the bug

The following test passes!

import { expect, test } from 'vitest';

test('huh', () => {
  expect(1).toBe(2);
});

With this config:

import { defineConfig } from 'vitest/config';

export default defineConfig({
  test: {
    include: ['**/*.test.ts'],
    typecheck: {
      enabled: true,
      ignoreSourceErrors: true,
      include: ['**/*.test.ts'],
    },
  },
});

Note: commenting out the whole typecheck prop makes the test fail as expected, as does commenting out typecheck.include.

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-hw9uz6?file=test/huh.test.ts

You can also repro with the zod repo by putting a bad assertion in one of the tests and observing that they continue to pass.

(FYI @colinhacks because of this zod might have a bunch of broken tests on the v4 branch - that's where I found this, with vitest ^1.6.0, not sure about other branches)

Note: with "vitest": "latest" the "Tests" still pass but there's an unhandled error with no extra info.

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    vitest: 2.0.3 => 2.0.3

Used Package Manager

npm

Validations

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