我正在使用带有 typescript 和 Jasmine 的 webdriverIO 6,最近(在将 @wdio/sync 升级到 6.10.11 之后,我不确定这是否是巧合)我注意到我在测试运行期间遇到了一些新错误 - 之前在每个“它”之后:
Starting ChromeDriver 88.0.4324.96 on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
[0-0] RUNNING in chrome - /dist/specs/main.spec.js
[0-0] 2021-01-28T14:28:25.059Z ERROR @wdio/sync: TypeError: hook.apply is not a function
at execHook (/Users/marian/projects/***e2e/node_modules/@wdio/sync/build/executeHooksWithArgs.js:21:31)
[0-0] Error in "BeforeTest Hook"
hook.apply is not a function
[0-0] Opened url: ***
[0-0] 2021-01-28T14:28:28.826Z ERROR @wdio/sync: TypeError: hook.apply is not a function
at execHook (/Users/marian/projects/-e2e/node_modules/@wdio/sync/build/executeHooksWithArgs.js:21:31)
[0-0] Error in "AfterTest Hook"
hook.apply is not a function
在 wdio/sync 升级到 6.11.00 之后,它仍然是这样。
这是我的堆栈:
"devDependencies": {
"@types/jasmine": "^3.6.2",
"@types/node": "^14.14.20",
"@typescript-eslint/eslint-plugin": "^4.12.0",
"@typescript-eslint/parser": "^4.12.0",
"@wdio/cli": "^6.11.3",
"@wdio/devtools-service": "^6.11.0",
"@wdio/jasmine-framework": "6.6.3",
"@wdio/local-runner": "^6.11.3",
"@wdio/spec-reporter": "^6.11.0",
"@wdio/sync": "6.11.0",
"eslint": "^7.17.0",
"eslint-config-standard": "^16.0.2",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"wdio-chromedriver-service": "^6.0.4"
},
"dependencies": {
"@rpii/wdio-html-reporter": "~6.1.1",
"@slack/web-api": "^5.15.0",
"@wdio/reporter": "^6.11.0",
"chromedriver": "^88.0.0",
"typescript": "4.1.3",
"wdio-timeline-reporter": "^5.1.4"
}
在 wdio.conf.js 中,我只使用了一个钩子,这不是导致问题的原因,因为它最后只触发一次(onComplete())并且评论它没有任何区别。
我还使用了扩展 WDIOreporter 的 CustomReporter 并在那里使用 onTestPass() 和 onTestFail() 方法,但即使禁用整个报告器也没有任何区别。
我查看了 executeHooksWithArgs.js:21:31 但这对我没有任何意义,除了这部分负责钩子。
我尝试回到@wdio/sync 6.6.0(我在升级之前使用的)失败了,在同一个文件中出现了类似的错误:
ERROR @wdio/local-runner: Failed launching test session: TypeError: hooks.map is not a function
at Object.executeHooksWithArgs (/Users/marian/projects/***/node_modules/@wdio/sync/build/executeHooksWithArgs.js:16:19)
(...) Error: Could not find job
困扰我的是我有另一个具有类似设置且没有错误的项目,我正在同时升级它们。我什至不知道该往哪里看。