Skip to content

Conversation

@9aoy
Copy link
Collaborator

@9aoy 9aoy commented Dec 17, 2025

Summary

fix: should respect config.root option. support run sub-project tests with specified config & root configuration in monorepo's root.

https://rstest.rs/config/test/root

image

Related Links

Checklist

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

Copilot AI review requested due to automatic review settings December 17, 2025 04:08
@netlify
Copy link

netlify bot commented Dec 17, 2025

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit 3e47711
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/69422ca57de78e00081889e5
😎 Deploy Preview https://deploy-preview-778--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 fixes config.root handling to support running sub-project tests with specified config in monorepo setups. Previously, the CLI's root option would override the config file's root setting. Now, the config file's root is properly respected.

Key changes:

  • Separated the concept of cwd (where to look for config) from root (project root from config)
  • Added fallback logic to set config.root to cwd if not specified in config
  • Updated example configs to explicitly set root: __dirname

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
packages/core/src/cli/init.ts Refactored resolveConfig to accept cwd instead of root, added fallback logic for config.root
examples/node/rstest.config.ts Added explicit root: __dirname to example config
e2e/projects/fixtures/packages/client/rstest.config.ts Added root: __dirname to each project configuration
e2e/projects/index.test.ts Added test to verify config root is respected when specified via -c flag

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

Comment on lines +118 to +122
const mergedConfig = mergeWithCLIOptions(config, options);

if (!mergedConfig.root) {
mergedConfig.root = options.cwd;
}
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

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

The mergeWithCLIOptions function includes 'root' in its keys array (line 52), which causes it to override config.root with options.root when the --root CLI flag is provided. This defeats the purpose of this PR, which is to respect the config file's root setting.

The issue: when options.root is provided via CLI (e.g., --root packages/client), it's still a relative string that gets copied into config.root, potentially overriding an absolute path like __dirname from the config. Later, in RstestCore, this relative path would be resolved using the wrong base, resulting in incorrect paths like /monorepo/packages/client/packages/client.

The solution: Remove 'root' from the keys array in mergeWithCLIOptions (line 52). This way:

  • If the config has a root, it's preserved
  • If the config doesn't have a root, the fallback at lines 120-122 sets it to options.cwd
  • The CLI --root only affects where to look for the config file (via options.cwd), not the final config.root

This aligns with the PR's intent to respect the config file's root setting while allowing --root to control where configs are loaded from.

Copilot uses AI. Check for mistakes.
@9aoy 9aoy merged commit cae9e6c into main Dec 17, 2025
23 checks passed
@9aoy 9aoy deleted the config-root branch December 17, 2025 05:43
@9aoy 9aoy mentioned this pull request Dec 18, 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