Skip to content

feat: export mergeProjectConfig method#773

Merged
9aoy merged 1 commit intomainfrom
mergeProjectConfig
Dec 16, 2025
Merged

feat: export mergeProjectConfig method#773
9aoy merged 1 commit intomainfrom
mergeProjectConfig

Conversation

@9aoy
Copy link
Collaborator

@9aoy 9aoy commented Dec 16, 2025

Summary

export mergeProjectConfig method.

Related Links

Checklist

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

Copilot AI review requested due to automatic review settings December 16, 2025 03:58
@netlify
Copy link

netlify bot commented Dec 16, 2025

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit f2b03a1
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/6940d8fddea34400082757d8
😎 Deploy Preview https://deploy-preview-773--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
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 exports the mergeProjectConfig utility method from the @rstest/core package, making it available for external use alongside the existing mergeRstestConfig function. The new function is a convenience wrapper that merges ProjectConfig objects (which represent individual project configurations within a multi-project setup) using the existing mergeRstestConfig implementation.

  • Adds a new exported function mergeProjectConfig that wraps mergeRstestConfig with a type cast
  • Exports the new function from the main package entry point

Reviewed changes

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

File Description
packages/core/src/config.ts Implements the new mergeProjectConfig function that delegates to mergeRstestConfig with a type cast
packages/core/src/index.ts Adds mergeProjectConfig to the public API exports

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +79 to +82
export const mergeProjectConfig = (
...configs: ProjectConfig[]
): ProjectConfig => {
return mergeRstestConfig(...configs) as ProjectConfig;
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

The type cast from RstestConfig to ProjectConfig is potentially unsafe. Since mergeRstestConfig can include properties like reporters, pool, coverage, etc. that are explicitly omitted from ProjectConfig, the returned object may contain properties that violate the ProjectConfig type contract. Consider implementing a proper merge function that only handles ProjectConfig properties, or add runtime filtering to remove the omitted properties before returning.

Suggested change
export const mergeProjectConfig = (
...configs: ProjectConfig[]
): ProjectConfig => {
return mergeRstestConfig(...configs) as ProjectConfig;
// Helper to pick only ProjectConfig properties from an object
function pickProjectConfigProps(obj: any): ProjectConfig {
// List of allowed ProjectConfig keys. Update this list if ProjectConfig changes.
const allowedKeys = [
'root',
'include',
'exclude',
'testTimeout',
'testMatch',
'testEnvironment',
'globals',
'setupFiles',
'teardownFiles',
'transform',
'moduleNameMapper',
'extensionsToTreatAsEsm',
'watch',
'silent',
'bail',
'maxWorkers',
'snapshotFormat',
'snapshotSerializers',
'resolver',
'testSequencer',
'testPathIgnorePatterns',
'testRegex',
'testRunner',
'testURL',
'verbose',
// Add more keys as needed if ProjectConfig changes
];
return Object.fromEntries(
Object.entries(obj).filter(([key]) => allowedKeys.includes(key))
) as ProjectConfig;
}
export const mergeProjectConfig = (
...configs: ProjectConfig[]
): ProjectConfig => {
const merged = mergeRstestConfig(...configs);
return pickProjectConfigProps(merged);

Copilot uses AI. Check for mistakes.
Comment on lines +79 to +83
export const mergeProjectConfig = (
...configs: ProjectConfig[]
): ProjectConfig => {
return mergeRstestConfig(...configs) as ProjectConfig;
};
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

The newly exported mergeProjectConfig function lacks test coverage. Since the repository has comprehensive tests for mergeRstestConfig in packages/core/tests/config.test.ts, consider adding tests for mergeProjectConfig to ensure it correctly merges ProjectConfig objects and doesn't inadvertently include properties that should be omitted from ProjectConfig.

Copilot uses AI. Check for mistakes.
@9aoy 9aoy merged commit dd67985 into main Dec 16, 2025
23 checks passed
@9aoy 9aoy deleted the mergeProjectConfig branch December 16, 2025 05:53
@9aoy 9aoy mentioned this pull request Dec 16, 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.

1 participant