Using Pipelines to run Detox Tests for iOS

Hello!

Has anyone set up the bitrise pipelines to run their Detox tests? I am having trouble building the app in one stage and then using the intermediate file to then run the tests on that build in a different stage.

My ideal pipeline would be
Stage 1 - Workflow 1 -Build the app
Stage 2 - Workflow 1 - Pull the app from stage 1, and run test suite 1
- Workflow 2- Pull the app from stage 1, and run test suite 2
- Workflow 3- Pull the app from stage 1, and run test suite 3
etc etc

But right now while I deploy the app in stage 1 workflow 1, it is not being picked up in stage 2 at all
Here is an excerpt from my bitrise.yml with the relevant workflows

pipelines:
  build-and-run-e2e-tests:
    stages:
    - build-ios: {}
    - test-ios: {}
stages:
  build-ios:
    workflows:
    - e2e-test-ios-build: {}
  test-ios:
    workflows:
    - run-e2e-accountNavigation: {}
    - run-e2e-appNavigation: {}
workflows:
  e2e-test-ios-build:
      steps:
      - activate-ssh-key@4:
          run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
      - git-clone@8.2: {}
      - cache-pull@2: {}
      - nvm@1:
          inputs:
          - node_version: 18.19.1
      - npm@1:
          inputs:
          - command: ci
      - script@1:
          inputs:
          - content: |-
              brew tap wix/brew
              brew install applesimutils
      - cocoapods-install@2: {}
      - xcode-build-for-test@3:
          inputs:
          - destination: generic/platform=iOS Simulator
      - deploy-to-bitrise-io@2:
          inputs:
          - deploy_path: ""
          - pipeline_intermediate_files: $BITRISE_TEST_BUNDLE_PATH:BITRISE_TEST_BUNDLE_PATH
      - cache-push@2: {}
    run-e2e-accountNavigation:
      steps:
      - pull-intermediate-files@1:
          inputs:
          - artifact_sources: build_ios.e2e-test-ios-build
      - script@1:
          inputs:
          - content: |-
              npx detox test -c ios.sim.debug.ci e2e/accountNavigation.test.ts --record-videos failing --artifacts-location ./artifacts/detox_artifacts/
      - deploy-to-bitrise-io@2:
          run_if: .IsBuildFailed
          is_always_run: true
          inputs:
          - is_compress: "true"
    run-e2e-appNavigation:
      steps:
      - pull-intermediate-files@1:
          inputs:
          - artifact_sources: build_ios.e2e-test-ios-build
      - script@1:
          inputs:
          - content: |-
              npx detox test -c ios.sim.debug.ci e2e/appNavigation.test.ts --record-videos failing --artifacts-location ./artifacts/detox_artifacts/
      - deploy-to-bitrise-io@2:
          run_if: .IsBuildFailed
          is_always_run: true
          inputs:
          - is_compress: "true"

The output for the from the Pull Intermediate Files step is

Input:
- artifact_sources: build_ios.e2e-test-ios-build
- verbose: false
- app_slug: [redacted]
- finished_stage: [{"created_at":"2024-04-09T16:46:43.771226Z","finished_at":"2024-04-09T17:01:40Z","id":"[Redacted]","name":"build-ios","put_on_hold_at":null,"started_at":"2024-04-09T16:46:46Z","status":"succeeded","triggered_at":"2024-04-09T16:46:44.769798Z","workflows":[{"credit_cost":null,"external_id":[Redacted],"finished_at":"2024-04-09T17:01:40Z","id":[Redacted],"name":"e2e-test-ios-build","started_at":"2024-04-09T16:46:46Z","status":{"Name":"succeeded","StatusLevel":5}}]}]
- bitrise_api_base_url: https://api.bitrise.io
- bitrise_api_access_token: *****
Getting the list of artifacts of 0 builds
Downloading 0 artifacts

Hi micahdasMA,

I believe there is a typo in YML:
The stage is build-ios and in the pull-intermediate-file there is build_ios as stage with an underscore and not a dash.
Would you try to fix that and see if the rest of it works?

Zsolt

Thank you! I caught that and am now able to pull the app in the subsequent stages by using the environment variable process.env.BITRISE_TEST_BUNDLE_PATH, as my binaryPath for the app in .detoxrc.js

I am now having some issues getting the app to launch however.

Here is the relevant workflow

  run-e2e-appNavigation:
    before_run:
    - _pull_test_bundle
    steps:
    - activate-ssh-key@4:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone@8.2: {}
    - cache-pull@2: {}
    - script@1:
        inputs:
        - content: |-
            brew tap wix/brew
            brew install applesimutils
    - script@1:
        inputs:
        - content: npx detox rebuild-framework-cache && npx detox test -c ios.sim.debug.ci
            e2e/appNavigation.test.ts --record-videos failing --artifacts-location
            ./artifacts/detox_artifacts/
    - deploy-to-bitrise-io@2:
        run_if: ".IsBuildFailed"
        is_always_run: true
        inputs:
        - is_compress: 'true'

I was able to see using remote access that the simulator is launching, but I get the error No Bundle URL present

I tried adding a step before to run the script react-native run ios but it takes a long time and is basically doing what was already dont in the first stage to build the app so there are not really any time savings