首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何依次运行两个不同wdio.config.js文件

如何依次运行两个不同wdio.config.js文件
EN

Stack Overflow用户
提问于 2020-01-09 01:18:31
回答 2查看 1.6K关注 0票数 1

我目前有两个配置不同的wdio.config.js文件。我怎么能一个接一个地运行这两个呢?有可能吗?

这是我在代码中如何定义的:

第一个config.js

代码语言:javascript
复制
const { join } = require('path');
require('@babel/register')

exports.config = {
    maxInstances: 3,
    runner: 'local',
    //
    specs: [
        './tests/specs/**/*.spec.js'
    ],
    //
    exclude: [
        // 'path/to/excluded/files'
    ],
    //
    //
    baseUrl: 'http://localhost:9174/',

    capabilities: {
        chromeBrowser: {
            capabilities: {
                browserName: 'chrome'
            }
        },
        App: {
            port: 4723,
            capabilities: {
                platformName: 'iOS',
                'appium:platformVersion': '12.4',
                'appium:orientation': 'PORTRAIT',
                'appium:noReset': true,
                'appium:newCommandTimeout': 240,
                "appium:platformName": "iOS",
                "appium:deviceName": "iPhone 8",
                "appium:bundleId": "com.app.debug",
            }
        },
    },

    services: ['appium'],
    /* appium: {

        args: {
            address: '127.0.0.1',
        }
    }, */

    //
    //logLevel: 'trace',
    //
    //deprecationWarnings: true,
    //
    //bail: 0,
    //
    waitforTimeout: 20000,
    //
    //connectionRetryTimeout: 90000,
    //
    //connectionRetryCount: 3,
    //
    services: ['selenium-standalone'],
    //
    //framework: 'jasmine',
    /* jasmineNodeOpts: 
    {   
    // Jasmine default timeout
    defaultTimeoutInterval: 60000,
    expectationResultHandler(passed, assertion) 
    {
      // do something
    }, */

    //
    //
}

第二个config.js

代码语言:javascript
复制
const { join } = require('path');
require('@babel/register')

exports.config = {
    runner: 'local',
    //
    specs: [
        './tests/specs/**/*.common.js'
    ],
    //
    exclude: [
        // 'path/to/excluded/files'
    ],
    //
    //

    capabilities: {

        App: {
            port: 4724,
            capabilities: {
                platformName: 'iOS',
                'appium:platformVersion': '13.2',
                'appium:orientation': 'PORTRAIT',
                'appium:noReset': true,
                'appium:newCommandTimeout': 240,
                "appium:deviceName": "iPhone 11",
                "appium:bundleId": "com.xyz.debug",
            }
        }
    },

    services: ['appium'],
    /* appium: {

        args: {
            address: '127.0.0.1',
        }
    }, */

    //
    //logLevel: 'trace',
    //
    //deprecationWarnings: true,
    //
    //bail: 0,
    //
    waitforTimeout: 20000,
    //
    //connectionRetryTimeout: 90000,
    //
    //connectionRetryCount: 3,
    //
    services: ['selenium-standalone'],
    //
    //framework: 'jasmine',
    /* jasmineNodeOpts: 
    {   
    // Jasmine default timeout
    defaultTimeoutInterval: 60000,
    expectationResultHandler(passed, assertion) 
    {
      // do something
    }, */

    //
    //
}

和我的package.json文件:

代码语言:javascript
复制
{
  "type": "module",
  "name": "appium-boilerplate",
  "version": "5.3.1",
  "description": "Run end to end tests with using the webapp and the mobile app",
  "scripts": {
    "android.sauce.rdc.app": "./node_modules/.bin/wdio ./config/saucelabs/wdio.android.rdc.app.conf.js",
    "consumer.app": "./node_modules/.bin/wdio ./config/wdio.consumer.app.conf.js",
    "android.browser": "./node_modules/.bin/wdio ./config/wdio.android.browser.conf.js",
    "ios.app": "./node_modules/.bin/wdio ./config/wdio.ios.app.conf.js",
    "ios.sauce.rdc.app": "./node_modules/.bin/wdio ./config/saucelabs/wdio.ios.rdc.app.conf.js",
    "ios.browser": "./node_modules/.bin/wdio ./wdio.conf.js",
    "real.browser": "./node_modules/.bin/wdio ./config/wdio.browser.conf.js",
    "lint": "eslint config tests",
    "build": "babel --presets es2015 -d lib/ src"
  },
  "dependencies": {
    "@babel/runtime": "^7.7.6",
    "esm": "^3.2.25"
  },
  "devDependencies": {
    "@babel/cli": "^7.7.5",
    "@babel/core": "^7.7.5",
    "@babel/preset-env": "^7.7.6",
    "@babel/preset-react": "^7.7.4",
    "@babel/register": "^7.7.4",
    "@babel/traverse": "^7.5.5",
    "@babel/types": "^7.5.5",
    "@wdio/appium-service": "^5.12.1",
    "@wdio/cli": "^5.12.4",
    "@wdio/jasmine-framework": "^5.16.15",
    "@wdio/local-runner": "^5.16.15",
    "@wdio/mocha-framework": "^5.16.15",
    "@wdio/sauce-service": "^5.12.1",
    "@wdio/selenium-standalone-service": "5.6.4",
    "@wdio/spec-reporter": "^5.16.11",
    "@wdio/sync": "^5.16.15",
    "appium": "^1.13.0",
    "babel-core": "^7.0.0-bridge.0",
    "babel-eslint": "^10.0.2",
    "chromedriver": "^78.0.1",
    "eslint": "^5.16.0",
    "eslint-config-standard": "^12.0.0",
    "eslint-plugin-import": "^2.18.2",
    "eslint-plugin-node": "^7.0.1",
    "eslint-plugin-promise": "^4.2.1",
    "eslint-plugin-standard": "^4.0.1",
    "eslint-plugin-wdio": "^5.12.1",
    "mocha": "^6.2.2",
    "node-fetch": "^2.3.0",
    "spectron": "^9.0.0",
    "wdio-chromedriver-service": "^5.0.2",
    "webdriverio": "^5.12.4"
  }
}

我想用一个命令运行第一个命令,然后再运行第二个命令。我怎样才能做到这一点呢?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-01-09 01:37:59

为两个配置文件创建单独的测试命令。然后在package.json中添加一个新脚本,用&&分隔两个测试命令。

https://stackoverflow.com/a/53809731/8903949

(或)

使用吞咽或低沉的任务。

票数 2
EN

Stack Overflow用户

发布于 2020-01-09 10:41:54

我也遇到过同样的情况。在本例中,我使用了一个shell脚本文件。

对于MAC和Linux:创建run.sh文件,然后使用命令sh run.sh

代码语言:javascript
复制
#!/bin/bash
npm run android.sauce.rdc.app
npm run consumer.app
npm run ...

对于Windows:创建run.bat文件,然后运行它。

代码语言:javascript
复制
npm run android.sauce.rdc.app
npm run consumer.app
npm run ...
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59650841

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档