react-native-navigation的迁移库

test.e2e.ios.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. runDetoxUsingMocha();
  33. } finally {
  34. if (process.env.CI) {
  35. exec.kill(`Simulator`);
  36. exec.kill(`CoreSimulator`);
  37. exec.execSync(`sleep 5`);
  38. }
  39. }
  40. }
  41. function run() {
  42. if (!exec.which(`fbsimctl`)) {
  43. throw new Error(`fbsimctl must be installed: "brew tap facebook/fb && brew install fbsimctl"`);
  44. }
  45. buildProjForDetox();
  46. e2e();
  47. }
  48. run();