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

The Node process exits via Node APIs when no test files found #5913

Closed
6 tasks done
Jinjiang opened this issue Jun 18, 2024 · 1 comment · Fixed by #5926
Closed
6 tasks done

The Node process exits via Node APIs when no test files found #5913

Jinjiang opened this issue Jun 18, 2024 · 1 comment · Fixed by #5926
Labels
p2-nice-to-have Not breaking anything but nice to have (priority)

Comments

@Jinjiang
Copy link

Jinjiang commented Jun 18, 2024

Describe the bug

When run Vitest via Node APIs, the Node process will exit when no test files found. What I expect is returning an error object or a special message instead (without the exit of the whole Node process).

Reproduction

https://github.com/Jinjiang/reproductions/tree/vitest-no-test-found-20240618

System Info

System:
    OS: macOS 15.0
    CPU: (8) arm64 Apple M1
    Memory: 75.66 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.1 - ~/.local/share/mise/installs/node/20/bin/node
    Yarn: 1.22.18 - ~/.yarn/bin/yarn
    npm: 10.2.4 - ~/.local/share/mise/installs/node/20/bin/npm
    pnpm: 9.0.6 - ~/Library/pnpm/pnpm
    bun: 1.0.29 - ~/.local/share/mise/installs/bun/latest/bin/bun
  Browsers:
    Safari: 18.0
  npmPackages:
    vite: ^5.3.1 => 5.3.1 
    vitest: ^1.6.0 => 1.6.0

Used Package Manager

pnpm

Validations

@AriPerkkio
Copy link
Member

The process.exit is coming from here:

// if run with --changed, don't exit if no tests are found
if (!files.length) {
// Report coverage for uncovered files
const coverage = await this.coverageProvider?.generateCoverage?.({ allTestsRun: true })
await this.reportCoverage(coverage, true)
this.logger.printNoTestFound(filters)
if (!this.config.watch || !(this.config.changed || this.config.related?.length)) {
const exitCode = this.config.passWithNoTests ? 0 : 1
process.exit(exitCode)
}
}

I think we should lift all process.exit calls above the startVitest() method.

@AriPerkkio AriPerkkio added p2-nice-to-have Not breaking anything but nice to have (priority) and removed pending triage labels Jun 18, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants