feat: support filter test by full test name#916
Conversation
Summary of ChangesHello @9aoy, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new feature that allows users to filter tests by their full name, providing more control over which tests are executed. It modifies the core testing logic to support this filtering and updates the documentation to explain the new functionality. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new feature to filter tests by their full name, using > as a delimiter between suite and test names. This is a great addition for more precise test selection. The changes include new e2e tests to verify this functionality and updated documentation in both English and Chinese.
My main feedback is on the implementation of the filtering logic in packages/core/src/runtime/runner/task.ts. The current approach uses a heuristic to decide which name format to match against, which can be brittle. I've suggested a more robust implementation that checks against both space-separated and >-separated full names, which should make the feature more reliable.
| const delimiter = testNamePattern?.toString().includes(TEST_DELIMITER) | ||
| ? TEST_DELIMITER | ||
| : ''; | ||
|
|
||
| if ( | ||
| testNamePattern && | ||
| !getTaskNameWithPrefix(test, '').match(testNamePattern) | ||
| !getTaskNameWithPrefix(test, delimiter).match(testNamePattern) | ||
| ) { | ||
| return true; | ||
| } |
There was a problem hiding this comment.
The current logic for determining which delimiter to use for constructing the test name is based on a heuristic (checking if testNamePattern contains >). This can be brittle. For example, if a test or suite name itself contains a > character, and a user tries to match it with a regex, the filtering might not work as expected.
A more robust approach would be to check the pattern against both possible full name formats (one with spaces, and one with >). This removes the need for the heuristic and makes the filtering more reliable and predictable.
if (testNamePattern) {
// Check against space-separated name for keyword matching.
const nameWithSpaces = getTaskNameWithPrefix(test, '');
if (nameWithSpaces.match(testNamePattern)) {
return false;
}
// Check against `>`-separated name for full name matching.
const nameWithDelimiter = getTaskNameWithPrefix(test, TEST_DELIMITER);
if (nameWithDelimiter.match(testNamePattern)) {
return false;
}
return true;
}
Deploying rstest with
|
| Latest commit: |
5fe4ffa
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://1ed905fb.rstest.pages.dev |
| Branch Preview URL: | https://filter-test-with-suite-name.rstest.pages.dev |
fi3ework
left a comment
There was a problem hiding this comment.
what if a test case contains >, e.g. expect('var a > b + c')
|
tbh i like this feature, even not for agent. i often directly copy and paste the full name and hope to run it with |
At the moment, we can’t distinguish whether |
Summary
support filter test by full test name.
Related Links
#911
Checklist