fix(test): discover config upward when running a single YAML case file - #3195
Open
dajiaohuang wants to merge 1 commit into
Open
dajiaohuang wants to merge 1 commit into
dajiaohuang wants to merge 1 commit into
Conversation
When midscene-test is invoked with a path to a single YAML file (e.g. midscene-test ./cases/example.yaml), resolveRunInput used the file's parent directory as both the project root and the config search root. The config was only looked for inside that directory, so a standard project layout with midscene.config.ts at the project root and cases under cases/ failed to load the config. discoverTestConfig now walks up parent directories until it finds a config, hits a package.json/.git boundary, or reaches the filesystem root. prepareTestRun resolves the project root to the discovered config's directory when no explicit --config is passed, so report, result, and relative YAML paths all anchor at the project root. Fixes web-infra-dev#3132.
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
Running
midscene-test ./cases/example.yamlagainst a freshly created project fails because the CLI used the YAML file's parent directory (e.g../cases/) as both the project root and the config search root. With the default template layout (midscene.config.tsat the project root, cases undercases/), the config was never discovered.Changes
discoverTestConfignow walks up parent directories until it findsmidscene.config.{ts,mjs}, hits apackage.json/.gitboundary, or reaches the filesystem root.prepareTestRunresolves the project root to the discovered config's directory when no explicit--configis passed, so reports, result files, and relative YAML discovery anchor at the real project root instead of the case file's directory.package.jsonboundary stop condition.Validation
npx nx build @midscene/testpassesnpx biome check packages/test/src/cli/ packages/test/tests/test-project-runner.test.tspassesnpx vitest run tests/test-project-runner.test.ts— 36/38 pass (the 2 pre-existing failures are caused by local Node 22.10.0 being below the repo's required ^22.12.0, which triggersERR_REQUIRE_ESMinside tsx; unrelated to this change). New tests for upward config discovery pass.Fixes #3132