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

Detox is flaky on Travis CI #452

Closed
yogevbd opened this issue Dec 6, 2017 · 11 comments
Closed

Detox is flaky on Travis CI #452

yogevbd opened this issue Dec 6, 2017 · 11 comments

Comments

@yogevbd
Copy link
Contributor

yogevbd commented Dec 6, 2017

Description

Tests fail to pass 80% of the time on Travis CI
Does not reproduce locally.

Device and verbose Detox logs

✓ hides topBar onScroll down and shows it on scroll up (5563ms)
detox info 53: Terminating com.reactnativenavigation.playground... 
detox info 53: com.reactnativenavigation.playground terminated 
detox info 54: Launching com.reactnativenavigation.playground... 
detox info 54: com.reactnativenavigation.playground launched. The stdout and stderr logs were recreated, you can watch them with:
        tail -F $HOME/Library/Developer/CoreSimulator/Devices/5BABCDC9-5EAF-4E60-96C0-F78309091348/data/tmp/detox.last_launch_app_log.{out,err} 
    1) set Tab Bar badge on a current Tab
detox info 55: Shutting down 5BABCDC9-5EAF-4E60-96C0-F78309091348... 
detox info 55: 5BABCDC9-5EAF-4E60-96C0-F78309091348 shut down 
  22 passing (3m)
  1 failing
  1) screen style
       set Tab Bar badge on a current Tab:
     Error: Error: Cannot perform action due to constraint(s) failure.
Exception with Action: {
  "Action Name" : "Tap",
  "Element Description" : "<RCTText:0x7fc296c57390; AX=Y; AX.label='Switch to tab based app'; AX.frame={{0, 25}, {16, 16}}; AX.activationPoint={8, 33}; AX.traits='UIAccessibilityTraitStaticText'; AX.focused='N'; frame={{0, 0}, {16, 16}}; alpha=1>",
  "Failed Constraint(s)" : "interactable",
  "All Constraint(s)" : "(!(isSystemAlertViewShown) && ((respondsToSelector(isAccessibilityElement) && isAccessibilityElement) || kindOfClass('UIView')) && (enabled && !(((kindOfClass('UIView') || respondsToSelector(accessibilityContainer)) && ancestorThatMatches(!(enabled))))) && interactable)",
  "Recovery Suggestion" : "Adjust element properties so that it matches the failed constraint(s)."
}
[
  {
    "Description" : "Cannot perform action due to constraint(s) failure.",
    "Error Domain" : "com.google.earlgrey.ElementInteractionErrorDomain",
    "Error Code" : "1",
    "File Name" : "GREYBaseAction.m",
    "Function Name" : "-[GREYBaseAction satisfiesConstraintsForElement:error:]",
    "Line" : "66"
  }
]
      at Client.execute (node_modules/detox/src/client/Client.js:66:13)
      at <anonymous>
child_process.js:644
    throw err;
    ^
Error: Command failed: node_modules/.bin/mocha e2e --opts e2e/mocha.opts --configuration ios.sim.release  --cleanup    
    at checkExecSyncError (child_process.js:601:13)
    at Object.execSync (child_process.js:641:13)
    at runMocha (/Users/travis/build/wix/react-native-navigation/node_modules/detox/local-cli/detox-test.js:61:6)
    at Object.<anonymous> (/Users/travis/build/wix/react-native-navigation/node_modules/detox/local-cli/detox-test.js:39:5)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Function.Module.runMain (module.js:676:10)
child_process.js:644
    throw err;
    ^
Error: Command failed: detox build --configuration ios.sim.release && detox test --configuration ios.sim.release --cleanup
    at checkExecSyncError (child_process.js:601:13)
    at Object.execSync (child_process.js:641:13)
    at Object.execSync (/Users/travis/build/wix/react-native-navigation/node_modules/shell-utils/src/exec.js:8:6)
    at run (/Users/travis/build/wix/react-native-navigation/scripts/test.e2e.ios.js:10:8)
    at Object.<anonymous> (/Users/travis/build/wix/react-native-navigation/scripts/test.e2e.ios.js:6:1)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-native-navigation@2.0.0 test-e2e-ios: `node ./scripts/test.e2e.ios.js "--release"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the react-native-navigation@2.0.0 test-e2e-ios script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/travis/.npm/_logs/2017-12-06T13_08_53_871Z-debug.log
The command "./scripts/travis-fold.sh "npm run test-e2e-ios -- --release"" exited with 1.
after_script
0.01s$ echo "BUILD FINISHED"
BUILD FINISHED
Done. Your build exited with 1.
@LeoNatan
Copy link
Contributor

LeoNatan commented Dec 6, 2017

We will regard this as a Detox bug for now until we can determine what the cause is. Since it only reproduces on Travis, it is very hard to debug. Thanks

@rotemmiz
Copy link
Member

rotemmiz commented Dec 6, 2017

@LeoNatan
Copy link
Contributor

LeoNatan commented Dec 6, 2017

@rotemmiz Now that we have a visual indicator, we could use a video recording feature to see what is going on. But since Travis doesn't have storage support, so it will be hard.

@DanielZlotin Were you able to reproduce locally?

@DanielZlotin
Copy link
Contributor

DanielZlotin commented Dec 6, 2017 via email

@heuism
Copy link

heuism commented Dec 8, 2017

Sorry @yogevbd, I am unsure have you tried on Circle CI as well? The issue is it most of the time pass, on both CI and local machine. But then Sometimes it just give me the issue with <NSMutableURLRequest...>

@LeoNatan I remember you have input in the thread #263 as well. But then I am not sure if this is already solved? Because the thread there is already a month late. thanks.

@stereodenis
Copy link

@LeoNatan
What am I doing wrong?
This is Travis error with example config

ChildProcessError: Command failed: applesimutils --simulator 9C7E2899-7A4D-4277-9DBE-9E873EAFFFA5 --bundle com.busfor.Busfor --setPermissions notifications=YES
    Error: BulletinBoard property list not found.
    
     `applesimutils --simulator 9C7E2899-7A4D-4277-9DBE-9E873EAFFFA5 --bundle com.busfor.Busfor --setPermissions notifications=YES` (exited with error code 253)
      
      at callback (../node_modules/child-process-promise/lib/index.js:33:27)
      at ChildProcess.exithandler (../child_process.js:282:5)
      at emitTwo (../events.js:126:13)
      at ChildProcess.emit (../events.js:214:7)
      at maybeClose (../internal/child_process.js:925:16)
      at Process.ChildProcess._handle.onexit (../internal/child_process.js:209:5)

@chadlwilson
Copy link

We had a very similar set of errors (failures due to system alerts popping over the app) with our react-native project, except running inside a corporate environment behind a proxy. Something in the app was causing access to the internet (we couldn't work it out at the time, but in retrospect it was possibly an image loaded from a public URL).

This was triggering a modal proxy user/pass input system alert view in the simulator which caused interactivity to be lost and the tests to fail. We worked around it by getting a proxy auth exemption as we couldn't work out which network requests we were making, but should have dug deeper probably. Sometimes we wouldn't get the pop-up - not sure whether the proxy was causing the intermittent issues, or something we were doing.

Not sure on the nature of the internet access available on Travis CI, or whether all the tests here are correctly mocked, but thought it might help someone dealing with flakey Detox tests caused by system alerts in a constrained CI environment.

@birkir
Copy link

birkir commented Dec 15, 2017

I am in the process of making detox work on travis.

I constantly get ReferenceError: device is not defined, like 1 in 10 gets through.

I have got that error locally as well. Maybe because I'm using jest but not mocha.

@adylevy
Copy link

adylevy commented Dec 24, 2017

@yogevbd We had the same issue with travis, ended up using bitrise which is 99% success rate and much faster.

@Crash--
Copy link
Contributor

Crash-- commented Jan 3, 2018

I had some time the : Error: BulletinBoard property list not found.issue on bitrise.

With the help of some screenshots, it appears that this error tell us that the simulator / app is not ready yet, when we try to launch the app.

In fact, it seems that detox timeout / resolves await device.launchApp even if the simulator is not up & ready.

I don't know how I can change the default timeout for detox.launchApp(), but after a few tests, here is my current workaround is to try/catch the launchApp() and relaunchApp() after a long sleep.

before(async () => {
  await detox.init(config, { launchApp: false });
   try {
     await device.launchApp({ permissions: { notifications: 'YES', calendar: 'YES' } });
   } catch (e) {
     console.log('It will certainly throw an exception, but lets sleep for 60000ms', e);
     await sleep(60000);
     await device.launchApp({ permissions: { notifications: 'YES', calendar: 'YES' } });
     console.log('hey, sleep is over. Crossed fingers');
  }
})
after(async () => {
    await deviceUtils.takeScreenshot('after_test');		    
    await detox.cleanup();
  })

Now my tests are green and here is my log:

(node:8531) DeprecationWarning: "--compilers" will be removed in a future version of Mocha; see https://git.io/vdcSr for more info
detox-server info 11:15:20: server listening on localhost:49353...
detox info 1: Searching for device matching iPhone 7... 
detox info 5: Booting device 9CB16873-88A3-4D3C-AC24-67C27AC818B3 
detox info 7: Uninstalling io.getknow... 
detox info 7: io.getknow uninstalled 
detox info 8: Installing /Users/vagrant/git/ios/build/Build/Products/Release-iphonesimulator/getknow.app... 
detox info 8: /Users/vagrant/git/ios/build/Build/Products/Release-iphonesimulator/getknow.app installed 
detox info 9: Trying to set permissions... 
It will certainly throw an exception, but lets sleep for 60000ms { ChildProcessError: Command failed: applesimutils --simulator 9CB16873-88A3-4D3C-AC24-67C27AC818B3 --bundle io.getknow --setPermissions notifications=YES,calendar=YES
Error: BulletinBoard property list not found.

 `applesimutils --simulator 9CB16873-88A3-4D3C-AC24-67C27AC818B3 --bundle io.getknow --setPermissions notifications=YES,calendar=YES` (exited with error code 253)
    at callback (/Users/vagrant/git/node_modules/child-process-promise/lib/index.js:33:27)
    at ChildProcess.exithandler (child_process.js:282:5)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
  name: 'ChildProcessError',
  code: 253,
  childProcess: 
   { ChildProcess: { [Function: ChildProcess] super_: [Object] },
     fork: [Function],
     _forkChild: [Function],
     exec: [Function],
     execFile: [Function],
     spawn: [Function],
     spawnSync: [Function: spawnSync],
     execFileSync: [Function: execFileSync],
     execSync: [Function: execSync] },
  stdout: 'A collection of utils for Apple simulators.\n\nUsage:\n    applesimutils --byId <simulator identifier> --bundle <bundle identifier> --setPermissions "<permission1>, <permission2>, ..."\n    applesimutils --byName <simulator name> --byOS <simulator OS version> --bundle <bundle identifier> --setPermissions "<permission1>, <permission2>, ..."\n    applesimutils --simulator <simulator name/identifier> --restartSB\n    applesimutils --list [--byName <simulator name>] [--byOS <simulator OS version>] [--byType <simulator OS version>] [--maxResults <int>]\n\nOptions:\n    --byId             Filters simulators by identifier\n    --byName           Filters simulators by name\n    --byType           Filters simulators by device type\n    --byOS             Filters simulators by operating system\n    --list             Lists available simulators\n    --setPermissions   Sets the specified permissions and restarts SpringBoard for the changes to take effect\n    --clearKeychain    Clears the simulator\'s keychain\n    --restartSB        Restarts SpringBoard\n    --bundle           The app bundle identifier\n    --maxResults       Limits the number of results returned from --list\n    --version, -v      Prints version\n    --help, -h         Prints usage\n\nAvailable Permissions:\n    calendar=YES|NO|unset\n    camera=YES|NO|unset\n    contacts=YES|NO|unset\n    health=YES|NO|unset\n    homekit=YES|NO|unset\n    location=always|inuse|never|unset\n    medialibrary=YES|NO|unset\n    microphone=YES|NO|unset\n    motion=YES|NO|unset\n    notifications=YES|NO|unset\n    photos=YES|NO|unset\n    reminders=YES|NO|unset\n    siri=YES|NO|unset\n    speech=YES|NO|unset\n\n\nFor more features, open an issue at https://github.com/wix/AppleSimulatorUtils\nPull-requests are always welcome!\n',
  stderr: 'Error: BulletinBoard property list not found.\n\n' }
detox info 10: Trying to set permissions... 
detox info 10: Permissions are set 
detox info 11: Launching io.getknow... 
detox info 11: io.getknow launched. The stdout and stderr logs were recreated, you can watch them with:
        tail -F $HOME/Library/Developer/CoreSimulator/Devices/9CB16873-88A3-4D3C-AC24-67C27AC818B3/data/tmp/detox.last_launch_app_log.{out,err} 
hey, sleep is over. Crossed fingers
  Login
   • 📸  init.png
    ✓ should have login button (3746ms)
    ✓ should show connexion screen after tap (607ms)
    ✓ should show home screen after login (11239ms)

@LeoNatan
Copy link
Contributor

LeoNatan commented Jan 4, 2018

@craSH— That’s AppleSimUtils issue. Please open an issue there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants