react-native-navigation的迁移库

test.e2e.ios.js 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. const _ = require('lodash');
  2. const exec = require('shell-utils').exec;
  3. const release = _.includes(process.argv, 'release');
  4. function buildProjForDetox() {
  5. const scheme = release ? `playground_release` : `playground`;
  6. const conf = release ? `Release` : `Debug`;
  7. const cmd = `RCT_NO_LAUNCH_PACKAGER=true
  8. cd ./playground/ios && xcodebuild
  9. build
  10. -scheme ${scheme}
  11. -project playground.xcodeproj
  12. -sdk iphonesimulator
  13. -configuration ${conf}
  14. -derivedDataPath ./DerivedData/playground`;
  15. if (exec.which(`xcpretty`)) {
  16. exec.execSync(`${cmd} | xcpretty && exit \${PIPESTATUS[0]}`);
  17. } else {
  18. exec.execSync(`${cmd}`);
  19. }
  20. }
  21. function runDetoxUsingMocha() {
  22. const detoxAppBuildPath = `playground/ios/DerivedData/playground/Build/Products/${release ? 'Release' : 'Debug'}-iphonesimulator/playground.app`;
  23. exec.execSync(`detoxAppBuildPath="${detoxAppBuildPath}"
  24. BABEL_ENV=test
  25. ./node_modules/mocha/bin/mocha e2e
  26. --timeout ${2 * 60 * 1000}
  27. --recursive
  28. --bail`);
  29. }
  30. function e2e() { //eslint-disable-line
  31. try {
  32. if (process.env.CI) {
  33. exec.execSync(`yarn run start &`);
  34. exec.execSync(`sleep 5`);
  35. }
  36. runDetoxUsingMocha();
  37. } finally {
  38. if (process.env.CI) {
  39. exec.kill(`react-native/local-cli/cli.js start`);
  40. exec.kill(`Simulator`);
  41. exec.kill(`CoreSimulator`);
  42. exec.execSync(`sleep 5`);
  43. }
  44. }
  45. }
  46. function run() {
  47. if (!exec.which(`fbsimctl`)) {
  48. throw new Error(`fbsimctl must be installed: "brew tap facebook/fb && brew install fbsimctl"`);
  49. }
  50. buildProjForDetox();
  51. e2e();
  52. }
  53. run();