Search code examples
react-nativetravis-cidetox

How can i get the result of a test (fail/pass) written in to a variable/file when testing with Detox on TravisCI


Im building my React Native app with TravisCI and using Detox to run E2E on the version.

The Detox test results are printed to the travis console but i need to know fail or pass in an env var so i could act on it.

The test command is:

detox test --configuration ios.sim.debug

So i've tried:

export SANITY_RES=$(detox test --configuration ios.sim.debug)

but echo $SANITY_RES only contains:

configuration="ios.sim.debug" artifactsLocation="artifacts/ios.sim.debug.2018-12-25 14-42-58Z" node_modules/.bin/jest e2e --config=e2e/config.json --maxWorkers=1 '--testNamePattern=^((?!:android:).)$' detox[80481] INFO: [DetoxServer.js] server listening on localhost:51067...*

and not the final result. Any other way i could get them ?


Solution

  • Detox allows you the ability to write logs of your builds. See for more details https://github.com/wix/Detox/blob/master/docs/APIRef.Artifacts.md

    If you add —record-logs all as a flag to your detox test it will save all the logs of the build, change it to —record-logs failing if you only want logs of failing tests.

    You can even specify where the logs will be stored.