Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(runner): passWithNoTests option not work #4553

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/runner/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ export async function runSuite(suite: Suite, runner: VitestRunner) {
}

if (suite.mode === 'run') {
if (!hasTests(suite)) {
if (!runner.config.passWithNoTests && !hasTests(suite)) {
suite.result.state = 'fail'
if (!suite.result.errors?.length) {
const error = processError(new Error(`No test found in suite ${suite.name}`))
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions test/empty-test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "@vitest/test-empty-test",
"type": "module",
"private": true,
"scripts": {
"test": "vitest run --passWithNoTests"
},
"devDependencies": {
"vitest": "workspace:*"
}
}
Empty file.
3 changes: 3 additions & 0 deletions test/empty-test/test/one.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { expect, test } from 'vitest'

test('two', () => expect(1 + 1).toBe(2))
3 changes: 3 additions & 0 deletions test/empty-test/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { defineConfig } from 'vitest/config'

export default defineConfig({})
Loading