-
-
Notifications
You must be signed in to change notification settings - Fork 14
feat: add RSTEST_WORKER_ID environment variable
#641
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
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.
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 introduces the RSTEST_WORKER_ID environment variable to expose the worker ID to tests during execution. This allows tests to identify which worker they're running on, which can be useful for parallel execution scenarios and debugging.
- Adds
workerIdto theWorkerContexttype - Sets the
RSTEST_WORKER_IDenvironment variable in the worker process based on the entry index - Includes a test to verify the environment variable is available
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/core/src/types/worker.ts | Adds workerId field to WorkerContext type |
| packages/core/src/runtime/worker/index.ts | Sets RSTEST_WORKER_ID environment variable from context |
| packages/core/src/pool/index.ts | Passes workerId based on entry index to both test execution and collection |
| e2e/basic/test/index.test.ts | Adds test to verify RSTEST_WORKER_ID is defined |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| options: { | ||
| entryInfo, | ||
| context: { | ||
| workerId: index + 1, |
Copilot
AI
Oct 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using array index + 1 as workerId is problematic because multiple entries can execute on the same worker in a pool. This creates inconsistent worker IDs where the same worker process gets different IDs for different tests. The workerId should represent the actual worker process identifier from the pool, not the test entry index.
| workerId: index + 1, |
| options: { | ||
| entryInfo, | ||
| context: { | ||
| workerId: index + 1, |
Copilot
AI
Oct 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using array index + 1 as workerId is problematic because multiple entries can execute on the same worker in a pool. This creates inconsistent worker IDs where the same worker process gets different IDs for different tests. The workerId should represent the actual worker process identifier from the pool, not the test entry index.
| workerId: index + 1, | |
| // workerId will be set by the worker process itself |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Summary
add
RSTEST_WORKER_IDenvironment variable.Related Links
Checklist