Conversation
✅ Deploy Preview for rstest-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds support for passing configuration options to test environments through a new testEnvironment.options field. This enables users to configure environment-specific settings for jsdom and happy-dom, such as setting the URL or other constructor parameters.
Key changes:
- Extended
testEnvironmentconfig to accept both a string or an object withnameandoptionsfields - Updated runtime worker to pass options to environment setup functions
- Added comprehensive documentation in both English and Chinese with usage examples
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
packages/core/src/types/config.ts |
Added EnvironmentName and EnvironmentWithOptions types to support the new configuration format |
packages/core/src/types/environment.ts |
Minor formatting changes to interface definitions |
packages/core/src/config.ts |
Added normalization logic to convert string-based testEnvironment to object format |
packages/core/src/runtime/worker/index.ts |
Updated environment setup calls to pass options from configuration |
packages/core/src/runtime/worker/env/jsdom.ts |
Modified to accept options directly instead of nested jsdom property |
packages/core/src/runtime/worker/env/happyDom.ts |
Updated to accept options directly with default parameter handling |
packages/core/src/core/plugins/external.ts |
Updated to access testEnvironment.name instead of string value |
packages/core/src/core/plugins/basic.ts |
Updated to access testEnvironment.name instead of string value |
website/docs/en/config/test/test-environment.mdx |
Added documentation for environment options feature |
website/docs/zh/config/test/test-environment.mdx |
Added Chinese translation of environment options documentation |
e2e/dom/index.test.ts |
Added test case for custom environment options with jsdom |
e2e/dom/fixtures/test/envOptions.test.tsx |
New test file to verify custom URL option works correctly |
e2e/dom/fixtures/rstest.envOptions.config.ts |
New config file demonstrating environment options usage |
e2e/dom/utils.ts |
Updated to make testEnvironment parameter optional |
Comments suppressed due to low confidence (1)
e2e/dom/index.test.ts:57
- Test coverage for custom environment options is only added for jsdom but not for happy-dom. Consider adding a similar test for happy-dom to ensure consistent test coverage for the new feature across both environments.
describe('happy-dom', () => {
it('should run test correctly', async () => {
const { expectExecSuccess } = await runCli(appFilters, 'happy-dom');
await expectExecSuccess();
});
it('should load node built-in modules correctly', async () => {
const { expectExecSuccess } = await runCli('test/node', 'happy-dom');
await expectExecSuccess();
});
it('should run test correctly with custom externals', async () => {
const { expectExecSuccess } = await runCli(appFilters, 'happy-dom', {
args: externalConfigArgs,
});
await expectExecSuccess();
});
it('should run test correctly with jest-dom', async () => {
const { expectExecSuccess } = await runCli(jestDomFilters, 'happy-dom');
await expectExecSuccess();
});
});
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…-dev/rstest into testEnvironmentOptions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Support pass options to the test environment via
testEnvironment.optionsconfiguration. This is useful for configuringjsdomorhappy-dom. For example, you can set theurlforjsdom:#813
Related Links
Checklist