vitest: Error: No test suite found

Describe the bug

not sure what is happening, but if I comment the console.log() the test is fine, if that line is uncommented I get Error: No test suite found in file ...

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-7ztept?devtoolsheight=33&file=test/index.test.ts

System Info

System:
    OS: macOS 12.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 139.27 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 15.14.0 - ~/.nvm/versions/node/v15.14.0/bin/node
    Yarn: 1.22.15 - ~/.nvm/versions/node/v15.14.0/bin/yarn
    npm: 7.7.6 - ~/.nvm/versions/node/v15.14.0/bin/npm
  Browsers:
    Chrome: 98.0.4758.109
    Edge: 98.0.1108.62
    Firefox: 96.0.3
    Safari: 15.2
  npmPackages:
    @vitejs/plugin-react: ^1.2.0 => 1.2.0
    vitest: ^0.5.5 => 0.5.5

Used Package Manager

npm

Validations

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 22 (4 by maintainers)

Commits related to this issue

Most upvoted comments

Hi all,

I’m currently experiencing this issue:

image

Please reopen this, it’s still an issue if the root project folder doesn’t match the package name by case. In my case, the folder was “Engine”, the package name was “engine”.

Can you try the same with the previous version ("vitest": "0.5.4")?

I think that the last release (0.5.5) is shadowing real errors.

I’m noticing this issue when using pnpx (Monorepo using pnpm, my working directory is inside a library next to the testfile like project/packages/a/src/foo/, running pnpx vitest foo.spec.ts), using npx, vitest works fine.

Looks like the no test suite found error masking is fixed in the latest release

change vitest to npx vitest work for me

Can confirm errors are not shadowed on 0.5.4 with the following config (and a Failed to resolve import "@testing-library/jest-dom" from "src/test/setup.ts" shadowed error with 0.5.5)


/// <reference types="vitest" />
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

export default defineConfig({
  plugins: [react()],
  test: {
    environment: 'jsdom',
    globals: true,
    threads: false,
    watch: false,
    include: ['**/__tests__/*.{js,tsx,ts}'],
    setupFiles: './src/test/setup.ts'
  }
})