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(watch): don't indicate exit when no matching files #6968

Closed

Conversation

AriPerkkio
Copy link
Member

@AriPerkkio AriPerkkio commented Nov 26, 2024

Description

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

Copy link

netlify bot commented Nov 26, 2024

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit b82e5ea
🔍 Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/6748221aea5aa5000860fa5f
😎 Deploy Preview https://deploy-preview-6968--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@AriPerkkio AriPerkkio force-pushed the fix/watch-mode-no-matching-files branch from 4c7f1d5 to b82e5ea Compare November 28, 2024 07:56
@AriPerkkio AriPerkkio marked this pull request as ready for review November 28, 2024 07:56
@@ -426,7 +426,10 @@ export class Vitest {

this.logger.printNoTestFound(filters)

if (!this.config.watch || !(this.config.changed || this.config.related?.length)) {
if (this.config.watch) {
this.report('onFinished', [], [])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this breaks the lifecycle. There is usually at least onPathsCollected/onSpecsCollected call and onCollected

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, currently this is getting stuck in onInit which also breaks the lifecycle.

What would be better approach here? Should we call reporters' onInit after length of files has been checked?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would be a big breaking change, the assumption now is that we always call onInit. Maybe we shouldn't start timers in onInit?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what test reporters do with onInit in cases where test run didn't start. If we started timers in next onPathsCollected hook, we would get faster runs times in summary 😄

Looks like the internal junit reporter opens fs handle in onInit and closes it in onFinish. That logic sounds good to me. It's quite unexpected that onFinished is never called after onInit.

@@ -426,7 +426,10 @@ export class Vitest {

this.logger.printNoTestFound(filters)

if (!this.config.watch || !(this.config.changed || this.config.related?.length)) {
if (this.config.watch) {
Copy link
Member

@sheremet-va sheremet-va Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.globTestFiles can now also throw an error if you specify the : incorrectly and the banner won't disappear:

vitest some-test:10

Copy link
Member

@sheremet-va sheremet-va Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can also throw if git is not initialised and --changed flag is used

@AriPerkkio
Copy link
Member Author

Maybe after #7069 this could be solved

@AriPerkkio AriPerkkio deleted the fix/watch-mode-no-matching-files branch January 15, 2025 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants