vitest icon indicating copy to clipboard operation
vitest copied to clipboard

Error: No test suite found

Open massimopalmieri opened this issue 4 years ago • 22 comments

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

massimopalmieri avatar Feb 25 '22 08:02 massimopalmieri

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.

agualis avatar Feb 25 '22 09:02 agualis

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'
  }
})

elcoosp avatar Feb 25 '22 10:02 elcoosp

Yah, I can also confirm I was getting these No test suite found errors on 0.5.5, I downgraded to 0.5.4 and saw the actual error messages, fixed them, upgraded back up to 0.5.5 and everything passes.

erikpukinskis avatar Feb 26 '22 00:02 erikpukinskis

Ran into the same issue! Particularly with trying to call the following: import { mount } from "@vue/test-utils" In my case, it was as dumb of an error as forgetting to install the base test packages, but I couldn't deduce from the test output.

Downgraded from 0.5.5 to 0.5.4 which fixed it.

romansorin avatar Feb 26 '22 01:02 romansorin

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

rockwotj avatar Feb 26 '22 18:02 rockwotj

This was fixed, closing issue.

sheremet-va avatar May 08 '22 12:05 sheremet-va

I have the same error with the next config, I have tried to change the version but I cant see where is the trouble:

{ "devDependencies": { "standard": "^17.0.0", "vitest": "^0.23.1" }, "eslintConfig": { "extends": "./node_modules/standard/eslintrc.json" }, "name": "advent-js-tdd", "version": "1.0.0", "main": "index.js", "type": "module", "dependencies": { "acorn": "^8.8.0", "assertion-error": "^1.1.0", "chai": "^4.3.6", "check-error": "^1.0.2", "debug": "^4.3.4", "deep-eql": "^3.0.1", "esbuild": "^0.15.7", "esbuild-windows-64": "^0.15.7", "function-bind": "^1.1.1", "get-func-name": "^2.0.0", "has": "^1.0.3", "is-core-module": "^2.10.0", "local-pkg": "^0.4.2", "loupe": "^2.3.4", "ms": "^2.1.2", "nanoid": "^3.3.4", "path-parse": "^1.0.7", "pathval": "^1.1.1", "picocolors": "^1.0.0", "postcss": "^8.4.16", "resolve": "^1.22.1", "rollup": "^2.78.1", "source-map-js": "^1.0.2", "strip-literal": "^0.4.0", "supports-preserve-symlinks-flag": "^1.0.0", "tinybench": "^2.1.5", "tinypool": "^0.2.4", "tinyspy": "^1.0.2", "type-detect": "^4.0.8", "vite": "^3.1.0" }, "scripts": { "test": "vitest", "coverage": "vitest run --coverage" }, "keywords": [], "author": "", "license": "ISC", "description": "" }

And the test script: image

ferandgal avatar Sep 09 '22 10:09 ferandgal

In my case i've just changed the path to the project and now it works

VerseVent avatar Nov 14 '22 09:11 VerseVent

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".

n8allan avatar Dec 05 '22 05:12 n8allan

By default the test suite is the workspaceRoot. If that is not the case I recommend you hardcode the path.

jaumebalust avatar Dec 07 '22 10:12 jaumebalust

Hi all,

I'm currently experiencing this issue:

image

Rajivhost avatar Dec 12 '22 16:12 Rajivhost

v0.26.0 fixed this for me again 👍🏿

steve-py96 avatar Dec 19 '22 14:12 steve-py96

Experiencing this when upgrading to v0.26.1. It was not happening on the codebase with v0.25.2. Running in a monorepo and the folder name does not match package name so tried setting root and that did not help.
Running MacOS.

zachariahtimothy avatar Dec 20 '22 14:12 zachariahtimothy

Experiencing this when upgrading to v0.26.1. It was not happening on the codebase with v0.25.2. Running in a monorepo and the folder name does not match package name so tried setting root and that did not help. Running MacOS.

Seeing similar behaviour with 0.26.1.

just-Bri avatar Dec 21 '22 15:12 just-Bri

Can you please just open a new issue with reproduction? Commenting in closed issues doesn’t help maintainers.

sheremet-va avatar Dec 21 '22 15:12 sheremet-va

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.

AlexAegis avatar Dec 27 '22 23:12 AlexAegis

Also running into this error on vitest v0.26.3. Some of my tests are working, but in one directory of my repo, tests just will not run. Even something as basic as:

import { describe, expect, it } from 'vitest';

describe('A nascent test',()=>{
  it('Really basic test',()=>{
    expect(true).toBe(true);
  })
});

The above fails in one directory, but I have full test suits running fine in another. The error I get is: Error: No test suite found in file E:/Git/Kurohyou_studios/Roll20-Snippets/test_sheet/source/assets/js/__tests__/gen.test.js

Kurohyou avatar Jan 03 '23 17:01 Kurohyou

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".

Same here, in package.json the project name was DigiLab. When i've cloned it on my another notebook i typed 'digilab' and it gave me this error. After change the folder name it was fixed

RaczoOBY avatar Jan 18 '23 06:01 RaczoOBY

I changed the include property back and forth until it found the tests.

beckend avatar Feb 01 '23 08:02 beckend

change vitest to npx vitest work for me

LeeJim avatar Apr 20 '23 07:04 LeeJim