"ERROR @wdio/cli:utils: A service failed in the 'onPrepare'" hook when running local mobile auto tests

huangapple go评论74阅读模式
英文:

"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:

{
  &quot;name&quot;: &quot;my-new-project&quot;,
  &quot;type&quot;: &quot;module&quot;,
  &quot;devDependencies&quot;: {
    &quot;@wdio/appium-service&quot;: &quot;^8.11.2&quot;,
    &quot;@wdio/cli&quot;: &quot;^8.11.2&quot;,
    &quot;@wdio/local-runner&quot;: &quot;^8.11.2&quot;,
    &quot;@wdio/mocha-framework&quot;: &quot;^8.11.0&quot;,
    &quot;@wdio/spec-reporter&quot;: &quot;^8.11.2&quot;,
    &quot;appium&quot;: &quot;^2.0.0-rc.3&quot;,
    &quot;appium-uiautomator2-driver&quot;: &quot;^2.29.0&quot;
  },
  &quot;scripts&quot;: {
    &quot;wdio&quot;: &quot;wdio run ./wdio.conf.js&quot;
  }
}

This is wdio.conf.js:

export const config = {

    runner: &#39;local&#39;,
    
    port: 4724,
    path: &#39;/&#39;,
    specs: [
        &#39;./local_test.js&#39;
    ],
    
    exclude: [
        // &#39;path/to/excluded/files&#39;
    ],

    maxInstances: 10,

    capabilities: [{
        &quot;platformName&quot;: &quot;Android&quot;,
        &quot;appium:platformVersion&quot;: &quot;11&quot;,
        &quot;appium:deviceName&quot;: &quot;Redmi Note 11&quot;,
        &quot;appium:automationName&quot;: &quot;UIAutomator2&quot;,
        &quot;appium:app&quot;: &quot;C:\\VisualSC\\i_g_3_YT\\WikipediaSample.apk&quot;,
        &quot;appium:udid&quot;: &quot;my_udid&quot;,
      }],

    logLevel: &#39;error&#39;,

    bail: 0,

    baseUrl: &#39;http://localhost&#39;,

    waitforTimeout: 20000,

    connectionRetryTimeout: 120000,

    connectionRetryCount: 3,

    services: [&#39;appium&#39;],
    

    framework: &#39;mocha&#39;,

    reporters: [&#39;spec&#39;],


    mochaOpts: {
        ui: &#39;bdd&#39;,
        timeout: 60000
    },


}

And I use the Appium GUI

enter image description here

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 &#39;onPrepare&#39; hook
Error: Appium exited before timeout (exit code: 1)
    at ChildProcess.&lt;anonymous&gt; (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: &quot;ts-node/esm/transpile-only &#39;resolve&#39;&quot; 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&#39;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

huangapple
  • 本文由 发表于 2023年6月26日 08:19:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/76552899.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定