react-native-navigation的迁移库

test.e2e.ios.js 1.8KB

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