Skip to content

Commit

Permalink
fix(runner): passWithNoTests option not work (#4553)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing committed Nov 28, 2023
1 parent cb87f44 commit 8d183da
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 1 deletion.
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({})

0 comments on commit 8d183da

Please sign in to comment.