react-native-navigation的迁移库

e2e.ios.js 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. const _ = require('lodash');
  2. const shellUtils = require('shell-utils');
  3. const fs = require('fs');
  4. const release = _.includes(process.argv, 'release');
  5. function hackReactXcodeScript() {
  6. const fileToHack = `./node_modules/react-native/packager/react-native-xcode.sh`;
  7. const lines = _.split(String(fs.readFileSync(fileToHack)), '\n');
  8. lines[11] = release ? '' : `exit 0;`;
  9. fs.writeFileSync(fileToHack, _.join(lines, '\n'));
  10. }
  11. function buildProjForDetox() {
  12. const scheme = release ? `playground_release_Detox` : `playground_Detox`;
  13. const args = release ? '' : `GCC_PREPROCESSOR_DEFINITIONS="DEBUG=1 RCT_DEBUG=1 RCT_DEV=1 RCT_NSASSERT=1"`;
  14. shellUtils.exec.execSync(`RCT_NO_LAUNCH_PACKAGER=true \
  15. cd ios && xcodebuild \
  16. -scheme ${scheme} build \
  17. -project playground.xcodeproj \
  18. -sdk iphonesimulator \
  19. -derivedDataPath ./DerivedData/playground \
  20. ${args}`);
  21. }
  22. function e2e() {
  23. try {
  24. shellUtils.exec.kill(`detox-server`);
  25. shellUtils.exec.exec(`./node_modules/.bin/detox-server > ./detox-server.log 2>&1`);
  26. const detoxAppBuildPath = `ios/DerivedData/playground/Build/Products/${release ? 'Release' : 'Debug'}_Detox-iphonesimulator/playground.app`;
  27. shellUtils.exec.execSync(`detoxAppBuildPath="${detoxAppBuildPath}"
  28. BABEL_ENV=test
  29. ./node_modules/mocha/bin/mocha e2e
  30. --timeout 120000
  31. --recursive
  32. --compilers js:babel-register`);
  33. } finally {
  34. shellUtils.exec.kill(`detox-server`);
  35. if (release) {
  36. shellUtils.exec.kill(`Simulator`);
  37. shellUtils.exec.kill(`CoreSimulator`);
  38. }
  39. shellUtils.exec.execSync(`cat ./detox-server.log`);
  40. shellUtils.exec.execSync(`rm -f ./detox-server.log`);
  41. shellUtils.exec.execSync(`sleep 5`);
  42. }
  43. }
  44. function run() {
  45. hackReactXcodeScript();
  46. buildProjForDetox();
  47. e2e();
  48. }
  49. run();