英文:
"ERROR @wdio/cli:utils: A service failed in the 'onPrepare'" hook when running local mobile auto tests
问题
以下是您提供的内容的翻译:
这是 package.json 文件:
{
"name": "my-new-project",
"type": "module",
"devDependencies": {
"@wdio/appium-service": "^8.11.2",
"@wdio/cli": "^8.11.2",
"@wdio/local-runner": "^8.11.2",
"@wdio/mocha-framework": "^8.11.0",
"@wdio/spec-reporter": "^8.11.2",
"appium": "^2.0.0-rc.3",
"appium-uiautomator2-driver": "^2.29.0"
},
"scripts": {
"wdio": "wdio run ./wdio.conf.js"
}
}
这是 wdio.conf.js 文件:
export const config = {
runner: 'local',
port: 4724,
path: '/',
specs: [
'./local_test.js'
],
exclude: [
// 'path/to/excluded/files'
],
maxInstances: 10,
capabilities: [{
"platformName": "Android",
"appium:platformVersion": "11",
"appium:deviceName": "Redmi Note 11",
"appium:automationName": "UIAutomator2",
"appium:app": "C:\\VisualSC\\i_g_3_YT\\WikipediaSample.apk",
"appium:udid": "my_udid",
}],
logLevel: 'error',
bail: 0,
baseUrl: 'http://localhost',
waitforTimeout: 20000,
connectionRetryTimeout: 120000,
connectionRetryCount: 3,
services: ['appium'],
framework: 'mocha',
reporters: ['spec'],
mochaOpts: {
ui: 'bdd',
timeout: 60000
},
}
我使用 Appium GUI。
我在终端输入了以下命令:
PS C:\VisualSC\i_g_3_YT> npm run wdio
结果在运行代码时出现了这样的错误:
2023-06-25T23:43:13.006Z ERROR @wdio/cli:utils: A service failed in the 'onPrepare' hook
Error: Appium exited before timeout (exit code: 1)
at ChildProcess.<anonymous> (file:///C:/VisualSC/i_g_3_YT/node_modules/@wdio/appium-service/build/launcher.js:116:22)
at Object.onceWrapper (node:events:628:26)
at ChildProcess.emit (node:events:513:28)
at ChildProcess.emit (node:domain:489:12)
at ChildProcess._handle.onexit (node:internal/child_process:291:12)
Continue...
[0-0] Error: "ts-node/esm/transpile-only 'resolve'" did not call the next hook in its chain and did not explicitly signal a short circuit. If this is intentional, include `shortCircuit: true` in the hook's return.
[0-0] at new NodeError (node:internal/errors:399:5)
[0-0] at ESMLoader.resolve (node:internal/modules/esm/loader:846:13)
[0-0] at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:7)
[0-0] FAILED
Spec Files: 0 passed, 1 failed, 1 total (100% completed) in 00:00:07
如果您需要进一步的帮助或解决问题,请提供更多上下文和详细信息。
英文:
I'm a beginner, so therefore do not judge strictly for extra information
This is package.json:
{
"name": "my-new-project",
"type": "module",
"devDependencies": {
"@wdio/appium-service": "^8.11.2",
"@wdio/cli": "^8.11.2",
"@wdio/local-runner": "^8.11.2",
"@wdio/mocha-framework": "^8.11.0",
"@wdio/spec-reporter": "^8.11.2",
"appium": "^2.0.0-rc.3",
"appium-uiautomator2-driver": "^2.29.0"
},
"scripts": {
"wdio": "wdio run ./wdio.conf.js"
}
}
This is wdio.conf.js:
export const config = {
runner: 'local',
port: 4724,
path: '/',
specs: [
'./local_test.js'
],
exclude: [
// 'path/to/excluded/files'
],
maxInstances: 10,
capabilities: [{
"platformName": "Android",
"appium:platformVersion": "11",
"appium:deviceName": "Redmi Note 11",
"appium:automationName": "UIAutomator2",
"appium:app": "C:\\VisualSC\\i_g_3_YT\\WikipediaSample.apk",
"appium:udid": "my_udid",
}],
logLevel: 'error',
bail: 0,
baseUrl: 'http://localhost',
waitforTimeout: 20000,
connectionRetryTimeout: 120000,
connectionRetryCount: 3,
services: ['appium'],
framework: 'mocha',
reporters: ['spec'],
mochaOpts: {
ui: 'bdd',
timeout: 60000
},
}
And I use the Appium GUI
I entered this into the terminal
PS C:\VisualSC\i_g_3_YT> npm run wdio
And It turns out that such an error occurs when running the code:
2023-06-25T23:43:13.006Z ERROR @wdio/cli:utils: A service failed in the 'onPrepare' hook
Error: Appium exited before timeout (exit code: 1)
at ChildProcess.<anonymous> (file:///C:/VisualSC/i_g_3_YT/node_modules/@wdio/appium-service/build/launcher.js:116:22)
at Object.onceWrapper (node:events:628:26)
at ChildProcess.emit (node:events:513:28)
at ChildProcess.emit (node:domain:489:12)
at ChildProcess._handle.onexit (node:internal/child_process:291:12)
Continue...
[0-0] Error: "ts-node/esm/transpile-only 'resolve'" did not call the next hook in its chain and did not explicitly signal a short circuit. If this is intentional, include `shortCircuit: true` in the hook's return.
[0-0] at new NodeError (node:internal/errors:399:5)
[0-0] at ESMLoader.resolve (node:internal/modules/esm/loader:846:13)
[0-0] at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:7)
[0-0] FAILED
Spec Files: 0 passed, 1 failed, 1 total (100% completed) in 00:00:07
答案1
得分: 0
你需要通过以下方式安装 ts-node:
npm install ts-node --save-dev
英文:
You have to install ts-node via
npm install ts-node --save-dev
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论