Skip to content

feat: support filter projects via --project option#520

Merged
9aoy merged 5 commits intomainfrom
project-cli-option
Aug 29, 2025
Merged

feat: support filter projects via --project option#520
9aoy merged 5 commits intomainfrom
project-cli-option

Conversation

@9aoy
Copy link
Copy Markdown
Collaborator

@9aoy 9aoy commented Aug 28, 2025

Summary

Support filter projects via --project option.

For example, to match projects whose name is @test/a or @test/b:

rstest --project '@test/a' --project '@test/b'

You can also use wildcards to match project names:

rstest --project '@test/*'

You can exclude certain projects by negation:

rstest --project '!@test/a'

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@netlify
Copy link
Copy Markdown

netlify bot commented Aug 28, 2025

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit bf418a7
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/68b119fa00332000089fb8c6
😎 Deploy Preview https://deploy-preview-520--rstest-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 project configuration.

@9aoy 9aoy requested a review from fi3ework August 28, 2025 08:45
Copilot AI review requested due to automatic review settings August 29, 2025 03:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for filtering test projects via the --project command-line option. Users can now specify which projects to run using exact names, wildcards, or exclusion patterns.

Key changes include:

  • Added filterProjects utility function with support for wildcard and negation patterns
  • Updated CLI to accept the new --project option
  • Enhanced project resolution to apply filtering and provide helpful error messages

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/core/src/utils/testFiles.ts Added filterProjects function to filter projects by name patterns
packages/core/src/cli/init.ts Integrated project filtering into project resolution with error handling
packages/core/src/cli/commands.ts Added --project CLI option definition
packages/core/tests/utils/testFiles.test.ts Added comprehensive tests for the filterProjects function
e2e/projects/filter.test.ts Added end-to-end test for project filtering functionality
website/docs/*/guide/basic/test-filter.mdx Added documentation for project filtering feature
website/docs/*/guide/basic/cli.mdx Updated CLI documentation with new --project option
website/docs/*/config/test/projects.mdx Added cross-reference to project filtering
website/docs/*/config/test/name.mdx Enhanced documentation with examples and filtering context

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +53 to +57
const escaped = (isNeg ? pattern.slice(1) : pattern)
.split('*')
.map((part) => part.replace(/[.+?^${}()|[\]\\]/g, '\\$&'))
.join('.*');
return new RegExp(isNeg ? `^(?!${escaped})` : `^${escaped}$`);
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

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

The negation regex pattern ^(?!${escaped}) creates a negative lookahead that will match any string that doesn't start with the escaped pattern, but it doesn't anchor the end. This could lead to unexpected matches. It should be ^(?!${escaped}$).* to properly negate the entire pattern.

Suggested change
const escaped = (isNeg ? pattern.slice(1) : pattern)
.split('*')
.map((part) => part.replace(/[.+?^${}()|[\]\\]/g, '\\$&'))
.join('.*');
return new RegExp(isNeg ? `^(?!${escaped})` : `^${escaped}$`);
return new RegExp(isNeg ? `^(?!${escaped}$).*` : `^${escaped}$`);

Copilot uses AI. Check for mistakes.
options: CommonOptions;
}): Promise<Project[]> {
if (!config.projects || !config.projects.length) {
if (!config.projects) {
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

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

The condition only checks for falsy values but doesn't handle empty arrays. An empty projects array should also return early. The condition should be if (!config.projects || !config.projects.length) to match the original logic.

Suggested change
if (!config.projects) {
if (!config.projects || !config.projects.length) {

Copilot uses AI. Check for mistakes.
@9aoy 9aoy merged commit b1158c7 into main Aug 29, 2025
16 checks passed
@9aoy 9aoy deleted the project-cli-option branch August 29, 2025 06:54
@9aoy 9aoy mentioned this pull request Aug 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants