You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Bitrise/Browserstack配置ReactNative应用的Appium-wdio-Mocha测试?Bitrise支持吗?有无样本?

Absolutely, Bitrise fully supports running Appium + WebdriverIO (wdio) tests for React Native apps—both iOS and Android. Let me break down what you need to know, plus share a practical example setup that aligns with your existing project structure.

Does Bitrise Support Appium wdio Tests?

Yes, absolutely. Bitrise is built to handle mobile UI testing workflows, including Appium-based setups with wdio. Here’s why it fits your use case:

  • It offers pre-built steps for Node.js, Appium server setup, and React Native app building, which works seamlessly with your project’s shared package.json structure.
  • You can customize the build environment to install all your test dependencies (like wdio, Mocha, Appium drivers) via npm/yarn, just as you do locally.
  • It supports both local app builds (generating .ipa/.apk directly in the workflow) and using pre-built packages, so you can adapt it to either your Browserstack upload needs or direct device testing on Bitrise.
Example Setup & Configuration

Below’s a practical, project-aligned setup to get your wdio tests running on Bitrise:

1. Bitrise Workflow (bitrise.yml)

This workflow covers installing dependencies, starting Appium, building your React Native app, and running tests. You can split it into separate iOS/Android workflows if needed.

workflows:
  run-appium-wdio-tests:
    steps:
      # Standard repo setup
      - activate-ssh-key@4: {}
      - git-clone@8: {}
      
      # Set up Node.js to match your dev environment
      - node@2:
          inputs:
            - node_version: 18 # Use your project's actual Node version
      
      # Install all project dependencies (including test packages)
      - yarn@0:
          inputs:
            - command: install
      
      # Start Appium server in the background
      - script@1:
          inputs:
            - content: |
                # Start Appium on default port
                appium --port 4723 &
                # Wait for server to initialize
                sleep 10
      
      # Build iOS app (adjust paths/scheme to match your project)
      - react-native-build-ios@0:
          inputs:
            - project_path: ios/YourApp.xcworkspace
            - scheme: YourApp
            - export_method: ad-hoc
      
      # Run wdio iOS tests
      - script@1:
          inputs:
            - content: |
                npx wdio run wdio.ios.conf.js
      
      # Repeat similar steps for Android if needed:
      # - react-native-build-android@0: {}
      # - script@1: { inputs: { content: "npx wdio run wdio.android.conf.js" } }

2. WebdriverIO Configuration (wdio.ios.conf.js)

Tweak your wdio config to target the Bitrise-built app and local Appium server:

exports.config = {
  runner: 'local',
  specs: [
    './tests/**/*.spec.js' // Path to your existing test files
  ],
  capabilities: [{
    platformName: 'iOS',
    'appium:platformVersion': '16', // Match Bitrise's iOS simulator version
    'appium:deviceName': 'iPhone 14',
    'appium:automationName': 'XCUITest',
    'appium:app': './ios/build/YourApp.ipa', // Path to the built IPA in Bitrise
    'appium:noReset': true // Optional: Preserve app state between tests
  }],
  framework: 'mocha',
  mochaOpts: {
    ui: 'bdd',
    timeout: 60000
  },
  services: ['appium'],
  // Add other wdio settings as needed for your tests
}

For Android, create a similar wdio.android.conf.js file, adjusting platformName, appium:app (point to your .apk path), and automationName to UIAutomator2.

3. Key Tips for Your Project

  • Leverage package.json Scripts: Add test shortcuts to your package.json for cleaner workflow code:
    "scripts": {
      "test:wdio:ios": "npx wdio run wdio.ios.conf.js",
      "test:wdio:android": "npx wdio run wdio.android.conf.js"
    }
    
    Then in Bitrise’s Script step, just run yarn test:wdio:ios instead of the full command.
  • Browserstack Integration: If you need to upload builds to Browserstack from Bitrise, use the official Browserstack steps to upload your .ipa/.apk, then adjust your wdio config to point to Browserstack’s remote Appium server instead of the local one.
  • Dependency Checks: Ensure your package.json includes all required test dependencies, like @wdio/appium-service, @wdio/mocha-framework, appium, appium-xcuitest-driver, and appium-uiautomator2-driver.

内容的提问来源于stack exchange,提问作者user2451016

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 03:58:28