react-native-navigation的迁移库

test.e2e.ios.js 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. ONLY_ACTIVE_ARCH=YES`;
  16. if (exec.which(`xcpretty`)) {
  17. exec.execSync(`${cmd} | xcpretty && exit \${PIPESTATUS[0]}`);
  18. } else {
  19. exec.execSync(`${cmd}`);
  20. }
  21. }
  22. function runDetoxUsingMocha() {
  23. const detoxAppBuildPath = `playground/ios/DerivedData/playground/Build/Products/${release ? 'Release' : 'Debug'}-iphonesimulator/playground.app`;
  24. exec.execSync(`detoxAppBuildPath="${detoxAppBuildPath}"
  25. BABEL_ENV=test
  26. ./node_modules/mocha/bin/mocha e2e
  27. --timeout ${2 * 60 * 1000}
  28. --recursive
  29. --bail`);
  30. }
  31. function e2e() { //eslint-disable-line
  32. try {
  33. runDetoxUsingMocha();
  34. } finally {
  35. if (process.env.CI) {
  36. exec.kill(`Simulator`);
  37. exec.kill(`CoreSimulator`);
  38. exec.execSync(`sleep 5`);
  39. }
  40. }
  41. }
  42. function run() {
  43. if (!exec.which(`fbsimctl`)) {
  44. throw new Error(`fbsimctl must be installed: "brew tap facebook/fb && brew install fbsimctl"`);
  45. }
  46. buildProjForDetox();
  47. e2e();
  48. }
  49. run();