webdriverio/webdriverio

[🐛 Bug]: Spec CLI arg breakable on Windows

Open

#12,983 创建于 2024年6月5日

在 GitHub 查看
 (6 评论) (0 反应) (0 负责人)JavaScript (1,793 fork)batch import
Bug 🐛help wanted

仓库指标

Star
 (6,029 star)
PR 合并指标
 (平均合并 15天 15小时) (30 天内合并 48 个 PR)

描述

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

8.38.2

Node.js Version

20.X and 22.2.0

Mode

WDIO Testrunner

Which capabilities are you using?

No response

What happened?

When trying to use the "spec" cli arg on Windows with a glob pattern, the runner fails to find matching spec files -- even when the output pattern fully matches the structure and there are tests.

As an example, say I ran something like:

wdio ./configs/local-config.ts --spec /tests/some-folder/*.spec.ts

And assume the folder structure looks something like this:

- root
- - configs
- - - local-config.ts
- - tests
- - - some-folder
- - - - test1.spec.ts
- - - - test2.spec.ts
- - - another-folder
- - - - test3.spec.ts
- - - top-test.spec.ts

In v7, the test runner would have found test1.spec.ts and test2.spec.ts. When testing the upgrade to v8, I get an error that looks something like this:

Error: spec file(s) C:\Git\my-repo\tests\some-folder\*.spec.ts not found

I looked for related issues and the closest I found was this guy: https://github.com/webdriverio/webdriverio/issues/9495. But, it's marked closed. I also did some diagnosis to try and pinpoint the issue and it seems to be different than the one listed in 9495.

What is your expected behavior?

Like in v7, I would expect the test runner to locate test1.spec.ts and test2.spec.ts from the file glob pattern.

How to reproduce the bug.

I created a test repository that contains a reproducible example when run on a Windows machine: https://github.com/Xetoris/wdio-v8-spec-bug-example

Pull down that repo, npm install, and run npm run windows-error to see the error.

I did some digging through wdio-config to try and diagnose the issue. My findings are in the README and the mocha unit test that demonstrates what I think the error is.

Relevant log output

An example from the repo linked above on my Windows PC:


> wdio-v8-spec-bug-example@1.0.0 windows-error C:\Git\wdio-v8-spec-bug-example
> pnpm exec wdio ./wdio-example/config/config.ts --spec wdio-example/tests/filters/*.spec.ts

Error: spec file(s) C:\Git\wdio-v8-spec-bug-example\wdio-example\tests\filters\*.spec.ts not found
    at ConfigParser.setFilePathToFilterOptions (file:///C:/Git/wdio-v8-spec-bug-example/node_modules/.pnpm/@wdio+config@8.38.2/node_modules/@wdio/config/build/node/ConfigParser.js:344:19)
    at ConfigParser.merge (file:///C:/Git/wdio-v8-spec-bug-example/node_modules/.pnpm/@wdio+config@8.38.2/node_modules/@wdio/config/build/node/ConfigParser.js:190:39)
    at ConfigParser.initialize (file:///C:/Git/wdio-v8-spec-bug-example/node_modules/.pnpm/@wdio+config@8.38.2/node_modules/@wdio/config/build/node/ConfigParser.js:59:14)
    at async Launcher.run (file:///C:/Git/wdio-v8-spec-bug-example/node_modules/.pnpm/@wdio+cli@8.38.2_typescript@5.4.5/node_modules/@wdio/cli/build/launcher.js:39:9)
    at async Module.run (file:///C:/Git/wdio-v8-spec-bug-example/node_modules/.pnpm/@wdio+cli@8.38.2_typescript@5.4.5/node_modules/@wdio/cli/build/run.js:64:20)
 ELIFECYCLE  Command failed with exit code 1.



### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

### Is there an existing issue for this?

- [X] I have searched the existing issues

贡献者指南