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

feat: show more details when no test files found #1033

Merged
merged 7 commits into from
Apr 2, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions docs/config/index.md
Expand Up @@ -318,6 +318,27 @@ Isolate environment for each test file

Coverage options

### testNamePattern

- **Type** `string | RegExp`

Run tests with full names matching the pattern.
If you add `OnlyRunThis` to this property, tests containing the word `OnlyRunThis` in the test name will be skipped.

```js
import { expect, test } from 'vitest'

// run
test('OnlyRunThis', () => {
expect(true).toBe(true)
})

// skipped
test('doNotRun', () => {
expect(true).toBe(true)
})
```

### open

- **Type:** `boolean`
Expand Down
17 changes: 12 additions & 5 deletions packages/vitest/src/node/core.ts
Expand Up @@ -114,12 +114,19 @@ export class Vitest {
)

if (!files.length) {
if (this.config.passWithNoTests)
this.log('No test files found\n')
const exitCode = this.config.passWithNoTests ? 0 : 1
if (this.config.passWithNoTests) {
this.log(`No test files found, exiting code with ${exitCode}\n`)
}
else {
this.error(c.red(`No test files found, exiting code with ${exitCode}\nRun with \`--passWithNoTests\`to exit with code 0\n`))
console.error(`In ${c.bold(this.config.root)}`)
if (filters?.length) this.console.error(` filter: ${c.yellow(filters.join(', '))}`)
if (this.config.include) this.console.error(` include: ${c.yellow(this.config.include.join(', '))}`)
if (this.config.watchIgnore) this.console.error(` watchIgnore: ${c.yellow(this.config.watchIgnore.join(', '))}`)
}

else
this.error(c.red('No test files found\n'))
process.exit(this.config.passWithNoTests ? 0 : 1)
process.exit(exitCode)
}

await this.runFiles(files)
Expand Down