Skip to content

feat(cli): support restart rstest when config file changed#477

Merged
9aoy merged 6 commits intomainfrom
restart-rstest
Aug 15, 2025
Merged

feat(cli): support restart rstest when config file changed#477
9aoy merged 6 commits intomainfrom
restart-rstest

Conversation

@9aoy
Copy link
Copy Markdown
Collaborator

@9aoy 9aoy commented Aug 14, 2025

Summary

support restart rstest when config file changed.

image

Related Links

Checklist

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

Copilot AI review requested due to automatic review settings August 14, 2025 10:07
@netlify
Copy link
Copy Markdown

netlify bot commented Aug 14, 2025

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit 0ed5002
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/689dd815f439f60008a92741
😎 Deploy Preview https://deploy-preview-477--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.

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 implements automatic restart functionality for rstest when configuration files change during watch mode. When a config file is modified, the test runner will automatically restart to pick up the new configuration.

Key changes:

  • Adds file watching for configuration files to trigger restarts
  • Introduces a restart mechanism with proper cleanup handling
  • Excludes config files from rspack watching to prevent conflicts

Reviewed Changes

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

Show a summary per file
File Description
tests/watch/restart.test.ts Adds test coverage for config file change restart functionality
packages/core/src/utils/watchFiles.ts Utility for creating file watchers with glob pattern support
packages/core/src/core/restart.ts Core restart logic with cleanup handling and file watching
packages/core/src/core/runTests.ts Integrates restart mechanism into test runner
packages/core/src/core/rsbuild.ts Passes config file path to rspack plugin
packages/core/src/core/plugins/entry.ts Excludes config file from rspack watching
packages/core/src/core/index.ts Updates createRstest to accept config file path
packages/core/src/core/context.ts Adds config file path to context
packages/core/src/core/cliShortcuts.ts Fixes event listener cleanup
packages/core/src/cli/commands.ts Refactors command handling and adds restart watching
packages/core/package.json Adds chokidar dependency
packages/core/LICENSE.md Adds chokidar license
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@@ -0,0 +1,43 @@
import type { ChokidarOptions, FSWatcher } from 'chokidar';

export type WatchFilesResult = {
Copy link

Copilot AI Aug 14, 2025

Choose a reason for hiding this comment

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

The WatchFilesResult type is defined but never used in this file. Consider removing it or using it as the return type for createChokidar function if that was the intention.

Copilot uses AI. Check for mistakes.
}): Promise<boolean> => {
await beforeRestart({ filePath, clear });

await runRest({ options, filters, command: 'watch' });
Copy link

Copilot AI Aug 14, 2025

Choose a reason for hiding this comment

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

The restart function calls runRest with hardcoded 'watch' command, but it should use the original command parameter passed to the function to maintain the correct command context.

Suggested change
await runRest({ options, filters, command: 'watch' });
command,
}: {
options: CommonOptions;
filters: string[];
filePath?: string;
clear?: boolean;
command: string;
}): Promise<boolean> => {
await beforeRestart({ filePath, clear });
await runRest({ options, filters, command });

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,113 @@
import path from 'node:path';
import type { ChokidarOptions } from 'chokidar';
import { type CommonOptions, runRest } from '../cli/commands';
Copy link

Copilot AI Aug 14, 2025

Choose a reason for hiding this comment

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

Importing runRest from cli/commands creates a circular dependency risk since commands.ts imports from core modules. Consider moving runRest to a shared utility module.

Suggested change
import { type CommonOptions, runRest } from '../cli/commands';
import type { CommonOptions } from '../cli/commands';
import { runRest } from '../cli/runRestUtil';

Copilot uses AI. Check for mistakes.
@9aoy 9aoy merged commit f7a9ff4 into main Aug 15, 2025
26 checks passed
@9aoy 9aoy deleted the restart-rstest branch August 15, 2025 03:18
@9aoy 9aoy mentioned this pull request Aug 15, 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