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 (core): filter different projects in watch mode #7146

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

DevJoaoLopes
Copy link

@DevJoaoLopes DevJoaoLopes commented Dec 29, 2024

Description

closes #7131

  • This PR resolves a bug in watch (-watch) mode where the filter (w key) is not filtering only the tests of a given project

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 Dec 29, 2024

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 715eaf3
🔍 Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/677103f601658c00081ae386
😎 Deploy Preview https://deploy-preview-7146--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.

Copy link

netlify bot commented Dec 29, 2024

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit bac2ef7
🔍 Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/677f06ce9fc98d0008e5c7f3
😎 Deploy Preview https://deploy-preview-7146--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.

@DevJoaoLopes DevJoaoLopes force-pushed the fix-filter-watch-mode-projects branch from f41276b to 057e610 Compare December 29, 2024 18:15
@@ -830,11 +830,12 @@ export class Vitest {
}

const specifications = files.flatMap(file => this.getModuleSpecifications(file))
Copy link
Member

Choose a reason for hiding this comment

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

This should already return only filtered projects because it uses vitest.projects and not vitest.resolvedProjects. Why doesn't it?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, but in those cases where we have different projects defined by defineProject, the filter of files.flatMap(file => this.getModuleSpecifications(file)) is returning TestProjects beyond what it should.
Because of this, one of the possible solutions would be to apply the filter by name.

Copy link
Member

Choose a reason for hiding this comment

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

You just rephrased what I asked. Why does it do that? getModuleSpecification shouldn't include filtered out projects

Copy link
Author

Choose a reason for hiding this comment

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

Sorry, now I understand your question...
getModuleSpecification has the following validation:

const _cached = this.getCachedSpecifications(moduleId)
if (_cached) {
  return _cached
}

When we are re-running the tests with the filters along with --watch it ends up returning the cache projects instead of trying to search again. (Another solution would be to simply remove this validation and cache return).

Copy link
Author

Choose a reason for hiding this comment

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

@sheremet-va Do you have any idea what paths we can take to solve the problem? Insert validation into specificationsWithFilterByProject or remove cache validation for getModuleSpecification ?

test/filterWatchMode/package.json Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Project filter is includes shared tests across projects
2 participants