Skip to content

feat: re-run on demand in watch mode. #475

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

Merged
merged 5 commits into from
Aug 22, 2025
Merged

feat: re-run on demand in watch mode. #475

merged 5 commits into from
Aug 22, 2025

Conversation

fi3ework
Copy link
Member

@fi3ework fi3ework commented Aug 14, 2025

Summary

Rerun test files on demand, with following major modification:

  1. using a new Rstest class to hold the persistent test results, which will be used to do the partial update with.
  2. calculate the affected test entry files by the diff of the chunks, and rerun them as on-demand.

Related Links

Checklist

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

Copy link

netlify bot commented Aug 14, 2025

Deploy Preview for rstest-dev ready!

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

@fi3ework fi3ework force-pushed the watch branch 9 times, most recently from bad79e9 to 7b0ecd8 Compare August 21, 2025 10:01
@fi3ework fi3ework marked this pull request as ready for review August 21, 2025 10:35
@fi3ework fi3ework requested review from Copilot and 9aoy August 21, 2025 10:35
Copy link
Contributor

@Copilot 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 implements on-demand test re-running in watch mode by tracking build chunk changes and only running affected test files. It introduces a new Rstest class to replace the previous context approach and maintains persistent test results for partial updates.

  • Introduces a new Rstest class that maintains persistent test state and reporter results
  • Implements chunk-based change detection to identify affected test files in watch mode
  • Adds filtering capabilities to reporters to show results only for re-run tests

Reviewed Changes

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

Show a summary per file
File Description
packages/core/src/types/worker.ts Adds chunks field to EntryInfo type for tracking build chunks
packages/core/src/types/reporter.ts Adds optional filterRerunTestPaths parameter to reporter interface and updates import path
packages/core/src/runtime/api/poll.ts Removes biome-ignore comment for lint rule
packages/core/src/reporter/summary.ts Updates error log filtering to respect filterRerunTestPaths parameter
packages/core/src/reporter/index.ts Passes through filterRerunTestPaths to summary error logging
packages/core/src/reporter/githubActions.ts Adds filterRerunTestPaths parameter to interface (unused)
packages/core/src/core/runTests.ts Updates to use new Rstest class and implements on-demand test running logic
packages/core/src/core/rstest.ts New class replacing context pattern with persistent state management
packages/core/src/core/rsbuild.ts Implements chunk change detection and affected entry calculation
packages/core/src/core/index.ts Updates to instantiate Rstest class instead of using context function
packages/core/src/core/context.ts Removes old context creation logic (replaced by Rstest class)
e2e/watch/shortcuts.test.ts Updates tests to verify new debug logging behavior
e2e/watch/index.test.ts Updates tests to verify re-run detection and logging

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


// delete
cli.resetStd();
fs.delete('./fixtures-test-0/bar.test.ts');
await cli.waitForStdout('Duration');
expect(cli.stdout).toMatch('No test files are re-run.');
Copy link
Contributor

Choose a reason for hiding this comment

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

can we log removed files?

Copy link
Member Author

Choose a reason for hiding this comment

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

it only will log when DEBUG is enabled, i think it's okay to preserve for test and debug.

@fi3ework fi3ework force-pushed the watch branch 2 times, most recently from 111cbb9 to acb1f7b Compare August 22, 2025 03:10
@fi3ework fi3ework merged commit 46e9d4d into main Aug 22, 2025
16 checks passed
@fi3ework fi3ework deleted the watch branch August 22, 2025 06:24
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