Skip to content

fix(test): discover config upward when running a single YAML case file - #3195

Open
dajiaohuang wants to merge 1 commit into
web-infra-dev:mainfrom
dajiaohuang:fix/single-yaml-config-discovery
Open

dajiaohuang wants to merge 1 commit into
web-infra-dev:mainfrom
dajiaohuang:fix/single-yaml-config-discovery

Conversation

@dajiaohuang

Copy link
Copy Markdown
Contributor

Summary

Running midscene-test ./cases/example.yaml against 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.ts at the project root, cases under cases/), the config was never discovered.

Changes

  • discoverTestConfig now walks up parent directories until it finds midscene.config.{ts,mjs}, 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 reports, result files, and relative YAML discovery anchor at the real project root instead of the case file's directory.
  • Added regression tests covering upward config discovery and the package.json boundary stop condition.

Validation

  • npx nx build @midscene/test passes
  • npx biome check packages/test/src/cli/ packages/test/tests/test-project-runner.test.ts passes
  • npx 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 triggers ERR_REQUIRE_ESM inside tsx; unrelated to this change). New tests for upward config discovery pass.

Fixes #3132

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: midscene-test cannot run a single yaml case file

1 participant