Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2E Detox build and test in React Native (Android and iOS) #1374

Closed
12 tasks
gedenata opened this issue May 9, 2019 · 1 comment
Closed
12 tasks

E2E Detox build and test in React Native (Android and iOS) #1374

gedenata opened this issue May 9, 2019 · 1 comment

Comments

@gedenata
Copy link

gedenata commented May 9, 2019

React Native Environment Info:
    System:
      OS: macOS 10.14.4
      CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
      Memory: 201.32 MB / 8.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 12.2.0 - /usr/local/bin/node
      Yarn: 1.15.2 - /usr/local/bin/yarn
      npm: 6.9.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        API Levels: 19, 21, 22, 24, 28
        Build Tools: 27.0.3, 28.0.2, 28.0.3
        System Images: android-24 | Google Play Intel x86 Atom
    IDEs:
      Android Studio: 3.3 AI-182.5107.16.33.5314842
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.5.0 => 16.5.0 
      react-native: 0.57.0 => 0.57.0 
    npmGlobalPackages:
      react-native-cli: 2.0.1

Steps To Reproduce

  1. package.json
"scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
     "test": "jest",
    "build:ios-debug": "detox build -c ios.sim.debug",
    "build:ios-release": "detox build -c ios.sim.release",
    "build:android-debug": "detox build -c android.emu.debug",
    "build:android-release": "detox build -c android.emu.release",
    "test:ios-debug": "detox test -c ios.sim.debug -l verbose",
    "test:ios-release": "detox test -c ios.sim.release -l verbose",
    "test:android-debug": "detox test -c android.emu.debug -l verbose",
    "test:android-release": "detox test -c android.emu.release -l verbose",
    "e2e:ios-debug": "npm run build:ios-debug && npm run test:ios-debug",
    "e2e:ios-release": "npm run build:ios-release && npm run test:ios-release",
    "e2e:android-debug": "npm run build:android-debug && npm run test:android-debug",
    "e2e:android-release": "npm run build:android-release && npm run test:android-release"
  },
"dependencies": {
    "react": "16.5.0",
    "react-native": "0.57.0"
  },
"devDependencies": {
    "detox": "^12.6.1",
    "jest": "^23.6.0",
  },
"jest": {
    "preset": "react-native"
  },
"detox": {
    "test-runner": "jest",
    "runner-config": "e2e/config.json",
    "configurations": {
      "ios.sim.debug": {
        "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/MyApp.app",
        "build": "xcodebuild -project ios/MyApp.xcodeproj -scheme MyApp -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build -UseModernBuildSystem=NO -quiet",
        "type": "ios.simulator",
        "name": "iPhone 6"
      },
      "ios.sim.release": {
        "binaryPath": "ios/build/Build/Products/Release-iphonesimulator/MyApp.app",
        "build": "export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -project ios/MyApp.xcodeproj -scheme MyApp -configuration Release -sdk iphonesimulator -derivedDataPath ios/build -UseModernBuildSystem=NO -quiet",
        "type": "ios.simulator",
        "name": "iPhone 6"
      },
      "android.emu.debug": {
        "binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
        "build": "cd android; ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug; cd -",
        "type": "android.emulator",
        "name": "Nexus_5X_API_24"
      },
      "android.emu.release": {
        "binaryPath": "android/app/build/outputs/apk/release/app-release.apk",
        "build": "cd android; ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release; cd -",
        "type": "android.emulator",
        "name": "Nexus_5X_API_24"
      }
    }
  }
  1. e2e folder
    a. config.json
{
  "setupFilesAfterEnv": ["./init.js"],
  "testEnvironment": "node",
  "bail": true,
  "verbose": true
}

b. firstTest.spec.js

describe('Example', () => {
  beforeEach(async () => {
    await device.reloadReactNative();
  });

  it('should have welcome screen', async () => {
    await expect(element(by.id('welcome'))).toBeVisible();
  });

  it('should show hello screen after tap', async () => {
    await element(by.id('hello_button')).tap();
    await expect(element(by.text('Hello!!!'))).toBeVisible();
  });

  it('should show world screen after tap', async () => {
    await element(by.id('world_button')).tap();
    await expect(element(by.text('World!!!'))).toBeVisible();
  });
});

c. init.js

const detox = require('detox');
const config = require('../package.json').detox;
const adapter = require('detox/runners/mocha/adapter');

jest.setTimeout(480000);
jasmine.getEnv().addReporter(adapter);

beforeAll(async () => {
  await detox.init(config);
});

beforeEach(async function () {
  await adapter.beforeEach();
});

afterAll(async () => {
  await adapter.afterAll();
  await detox.cleanup();
});

d. mocha.opts

--recursive
--timeout 120000
--bail
--file e2e/init.js

Describe what you expected to happen:

  • npm run build:ios-debug
    => status: ** BUILD SUCCESSFUL **

  • npm run build:ios-release
    => status: ** BUILD FAILED **
    detox[807] ERROR: [cli.js] Error: Command failed: export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -project ios/MyApp.xcodeproj -scheme MyApp -configuration Release -sdk iphonesimulator -derivedDataPath ios/build -UseModernBuildSystem=NO -quiet

  • npm run build:android-debug
    => status: status: ** BUILD SUCCESSFUL **
    detox[2209] INFO: [build.js] cd android; ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug; cd -

  • npm run build:android-release
    => status: status: ** BUILD SUCCESSFUL **
    detox[2050] INFO: [build.js] cd android; ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release; cd -

  • npm run test:ios-debug
    => status: ** FAILED ** e2e/firstTest.spec.js
    Ran all test suites matching /e2e/i with tests matching "^((?!:android:).)$".
    detox[2269] ERROR: [cli.js] Error: Command failed: node_modules/.bin/jest --config=e2e/config.json --maxWorkers=1 '--testNamePattern=^((?!:android:).)
    $' "e2e"

  • npm run test:ios-release
    => status: same with test: npm run test:ios-debug

  • npm run test:android-debug
    => status: ** FAILED ** e2e/firstTest.spec.js
    detox[2339] ERROR: [cli.js] Error: Command failed: node_modules/.bin/jest --config=e2e/config.json --maxWorkers=1 '--testNamePattern=^((?!:ios:).)*$' "e2e"

  • npm run test:android-release
    => status: same with test: npm run test:android-debug

  • npm run e2e:ios-debug
    => status: absolutely error because above tests failed too

  • npm run e2e:ios-release
    => status: absolutely error because above tests failed too

  • npm run e2e:android-debug
    => status: absolutely error because above tests failed too

  • npm run e2e:android-release
    => status: absolutely error because above tests failed too

So, I need some help about E2E Detox React Native with Jest

Thank you guys.

@support
Copy link

support bot commented May 9, 2019

We use the issue tracker exclusively for bug reports and feature requests. This issue appears to be a general usage or support question. Instead, please ask a question on Stack Overflow with the detox tag.

@support support bot closed this as completed May 9, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant