react-native-navigation的迁移库

e2e.ios.js 2.2KB

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