Conversation
✅ Deploy Preview for rstest-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull Request Overview
This PR addresses a resource cleanup issue in e2e tests where child processes were not being properly terminated when tests failed, leading to lingering processes. The change ensures proper cleanup by adding a test lifecycle hook to kill child processes when tests finish.
Key Changes
- Adds automatic child process cleanup using rstest's
onTestFinishedhook - Prevents orphaned processes when e2e tests fail or complete
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| const cli = new Cli(process); | ||
|
|
||
| onTestFinished(() => { | ||
| cli.exec.kill(); |
There was a problem hiding this comment.
The code assumes cli.exec exists and has a kill() method, but there's no null check. If cli.exec is undefined or the process hasn't started yet, this will throw a runtime error. Consider adding a check like cli.exec?.kill(); or if (cli.exec) cli.exec.kill();
| cli.exec.kill(); | |
| cli.exec?.kill(); |
| onTestFinished(() => { | ||
| cli.exec.kill(); | ||
| }); | ||
|
|
There was a problem hiding this comment.
The onTestFinished callback is registered after cli.exec is created, but if the test fails immediately or the process exits quickly, there could be a race condition where the cleanup handler isn't registered in time. Consider registering the cleanup handler before starting the process or using a more robust cleanup mechanism.
onTestFinished to testContext
Summary
onTestFinishedto testContext. should useonTestFinishedhook from the test context when you are running tests concurrently.Related Links
Checklist