Detox icon indicating copy to clipboard operation
Detox copied to clipboard

device/element not found

Open nadzic opened this issue 8 years ago • 6 comments

Description

When I try to run detox tests element / device is not found. It works with example project from detox repo (demo-react-native-jest).

Steps to Reproduce

I run test with folllowing command: detox build --configuration ios.sim.debug && detox test --configuration ios.sim.debug

What I tried already: downgrade detox, downgrade node, different react native version (0.51, 0.52...), but still getting the same issue. Mazybe there should be some dependecy which causes it?

Our package.json

` { "name": "nintendo-app", "version": "0.1.0", "private": true, "devDependencies": { "babel-eslint": "^8.2.2", "babel-plugin-transform-runtime": "^6.0.0", "babel-preset-es2015": "^6.24.1", "babel-preset-flow": "^6.23.0", "babel-preset-jest": "^22.4.1", "babel-preset-react-native": "^4.0.0", "babel-preset-react-native-stage-0": "^1.0.1", "detox": "9.0.0", "enzyme": "^3.3.0", "enzyme-adapter-react-16": "^1.1.1", "enzyme-to-json": "^3.3.4", "eslint": "^4.18.2", "eslint-config-airbnb": "^16.1.0", "eslint-plugin-detox": "^1.0.0", "eslint-plugin-import": "^2.9.0", "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-react": "^7.7.0", "eslint-plugin-react-native": "^3.2.1", "fetch-mock": "^6.4.4", "identity-obj-proxy": "^3.0.0", "jest": "^23.1.0", "jest-environment-enzyme": "^6.0.1", "jest-enzyme": "^6.0.1", "jest-fetch-mock": "^1.6.4", "jest-react-native": "^18.0.0", "react-test-renderer": "16.2.0", "redux-mock-store": "^1.5.1" }, "scripts": { "start": "react-native start", "android": "react-native run-android", "ios": "react-native run-ios", "build:ios": "react-native bundle --entry-file='index.js' --bundle-output='./ios/nintendoapp/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'", "test:unit": "node node_modules/jest/bin/jest.js", "test:ios:release": "detox build -c ios.sim.release && detox test -c ios.sim.release", "test:ios:debug": "detox build --configuration ios.sim.debug && detox test --configuration ios.sim.debug", "test": "yarn test:unit && yarn test:ios:debug", "lint": "eslint .", "lint:fix": "eslint --fix .", "flow": "flow", "version": "./version-ios.sh" }, "jest": { "preset": "react-native", "modulePathIgnorePatterns": [ "/node_modules/./react-native/", "/node_modules/./react/" ], "testPathIgnorePatterns": [ "e2e", "node_modules" ], "transformIgnorePatterns": [ "/node_modules/(?!react-native|react-navigation)/" ], "moduleNameMapper": { ".+\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "identity-obj-proxy" }, "snapshotSerializers": [ "enzyme-to-json/serializer" ], "collectCoverageFrom": [ "js/**/*.{js}" ], "setupFiles": [ "./setupJest.js" ] }, "detox": { "test-runner": "jest", "runner-config": "e2e/config.json", "configurations": { "ios.sim.debug": { "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/nintendoapp.app", "build": "xcodebuild -project ios/nintendoapp.xcodeproj -UseNewBuildSystem=NO -scheme nintendoapp -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build", "type": "ios.simulator", "name": "iPhone 7 Plus" } } }, "dependencies": { "axios": "^0.18.0", "babel-preset-stage-0": "^6.24.1", "babel-jest": "21.2.0", "credit-card-type": "^7.1.0", "flow-bin": "0.73.0", "lodash": "^4.17.5", "prop-types": "^15.6.1", "rambda": "^1.0.12", "react": "16.2.0", "react-dom": "^16.4.0", "react-native": "0.52.0", "react-native-camera": "^1.1.2", "react-native-code-push": "^5.3.4", "react-native-device-info": "^0.21.5", "react-native-global-font": "^1.0.1", "react-native-keyboard-aware-scroll-view": "^0.5.0", "react-native-loader": "^1.2.1", "react-native-modal": "^5.2.0", "react-native-openanything": "^0.0.3", "react-native-qrcode-scanner": "^1.1.0", "react-native-side-menu": "^1.1.3", "react-native-view-overflow": "0.0.3", "react-navigation": "^1.4.0", "react-navigation-redux-helpers": "^1.0.3", "react-proptypes": "^1.0.0", "react-redux": "^5.0.7", "redux": "^3.7.2", "redux-axios-middleware": "^4.0.0", "redux-thunk": "^2.2.0", "websocket": "^1.0.25" }, "rnpm": { "assets": [ "./assets/fonts" ] } }

`

Detox, Node, Device, Xcode and macOS Versions

  • Detox: 9.0.0
  • React Native: 0.52.0
  • Node: 8.6.0
  • Device: Iphone 7 Plus
  • Xcode: 9.4.1
  • macOS: 10.13.16 Sierra

Device and verbose Detox logs

server listening on localhost:56316... : Searching for device matching iPhone 7 Plus... : Uninstalling com.ohmygreen.NintendoApp... : com.ohmygreen.NintendoApp uninstalled 5: Installing /Users/user/Documents/Repos/nintendo-app/ios/build/Build/Products/Debug-ipho esimulator/nintendoapp.app... 5: /Users/user/Documents/Repos/nintendo-app/ios/build/Build/Products/Debug-iphonesimulator nintendoapp.app installed : Terminating com.ohmygreen.NintendoApp... : com.ohmygreen.NintendoApp terminated : Launching com.ohmygreen.NintendoApp... 7: com.ohmygreen.NintendoApp launched. The stdout and stderr logs were recreated, you can watch them with: tail -F $HOME/Library/Developer/CoreSimulator/Devices/FCDB22C4-1926-45F0-8B75-1A99 2D6D5EC/data/tmp/detox.last_launch_app_log.{out,err} FAIL e2e/exampleTest.spec.js (132.393s) Example ✕ should have welcome screen (120841ms)

● Example › should have welcome screen

Timeout - Async callback was not invoked within the 120000ms timeout specified by jest.setTimeout.

  4 |   });
  5 | 
> 6 |   it('should have welcome screen', async () => {
    |   ^
  7 |     await expect(element(by.id('welcome'))).toBeVisible();
  8 |   });
  9 | });

  at new Spec (node_modules/jest-jasmine2/build/jasmine/Spec.js:85:20)
  at Suite.<anonymous> (e2e/exampleTest.spec.js:6:3)

Test Suites: 1 failed, 1 total Tests: 1 failed, 1 total Snapshots: 0 total Time: 133.343s Ran all test suites matching /e2e/i with tests matching "^((?!:android:).)*$". Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with --detectOpenHandles to troubleshoot this issue.

(this is log from version 7.3.5 detox (because I tried with different versions of detox, but no luck)).

nadzic avatar Oct 04 '18 07:10 nadzic

same here. and it happens randomly. currently no solution for that

EugeneNguyen avatar Oct 04 '18 10:10 EugeneNguyen

+1

hackdie avatar Oct 09 '18 16:10 hackdie

+1 ios 12 xcode 10

shishangx avatar Oct 10 '18 05:10 shishangx

Issue solved, for me the problem was I had loader on splash screen (beat moving loader), and if I did not hide/disable loader, when I went to next screen (react-navigation) then the detox returned this erros. Immediately after I replaced loader with for example Loading... it started working.

I hope it helps!

nadzic avatar Oct 11 '18 08:10 nadzic

In my case, this was an async issue. I solved it after doing some digging in Jest's docs (https://jestjs.io/docs/en/tutorial-async). Once I added babel-preset-env and the .babelrc file, the tests ran without any issues

edenadler avatar Oct 17 '18 15:10 edenadler

Please read issue comment https://github.com/wix/Detox/issues/911#issuecomment-433750839

I'm closing both issues.

rotemmiz avatar Oct 28 '18 23:10 rotemmiz