react-native-navigation的迁移库

e2e.ios.js 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. const _ = require('lodash');
  2. const shellUtils = require('shell-utils');
  3. const fs = require('fs');
  4. const release = _.includes(process.argv, 'release');
  5. function buildProjForDetox() {
  6. const scheme = release ? `playground_release` : `playground`;
  7. shellUtils.exec.execSync(`echo 'travis_fold:start:xcodebuild'`);
  8. const cmd = `RCT_NO_LAUNCH_PACKAGER=true
  9. cd ios && xcodebuild
  10. -scheme ${scheme}
  11. ${release ? 'clean build' : 'build'}
  12. -project playground.xcodeproj
  13. -sdk iphonesimulator
  14. -derivedDataPath ./DerivedData/playground`;
  15. if (hasXcpretty()) {
  16. shellUtils.exec.execSync(`${cmd} | xcpretty && exit \${PIPESTATUS[0]}`);
  17. } else {
  18. shellUtils.exec.execSync(`${cmd}`);
  19. }
  20. shellUtils.exec.execSync(`echo 'travis_fold:end:xcodebuild'`);
  21. }
  22. function hasXcpretty() {
  23. try {
  24. return shellUtils.exec.execSyncRead(`which xcpretty`);
  25. } catch (e) {
  26. return false;
  27. }
  28. }
  29. function e2e() { //eslint-disable-line
  30. try {
  31. shellUtils.exec.execSync(`echo 'travis_fold:start:detox-ios'`);
  32. shellUtils.exec.execSyncSilent(`watchman watch-del-all || true`);
  33. shellUtils.exec.kill(`detox-server`);
  34. shellUtils.exec.exec(`./node_modules/.bin/detox-server > ./detox-server.log 2>&1`);
  35. const detoxAppBuildPath = `ios/DerivedData/playground/Build/Products/${release ? 'Release' : 'Debug'}-iphonesimulator/playground.app`;
  36. shellUtils.exec.execSync(`detoxAppBuildPath="${detoxAppBuildPath}"
  37. BABEL_ENV=test
  38. ./node_modules/mocha/bin/mocha e2e
  39. --timeout 240000
  40. --recursive
  41. --compilers js:babel-register`);
  42. } finally {
  43. shellUtils.exec.kill(`detox-server`);
  44. if (process.env.CI) {
  45. shellUtils.exec.kill(`Simulator`);
  46. shellUtils.exec.kill(`CoreSimulator`);
  47. }
  48. shellUtils.exec.execSync(`cat ./detox-server.log`);
  49. shellUtils.exec.execSync(`rm -f ./detox-server.log`);
  50. shellUtils.exec.execSync(`sleep 5`);
  51. shellUtils.exec.execSync(`echo 'travis_fold:end:detox-ios'`);
  52. }
  53. }
  54. function run() {
  55. buildProjForDetox();
  56. e2e();
  57. }
  58. run();