你知道从 detox@12 到 detox@13 的重大变化吗?

Posted

技术标签:

【中文标题】你知道从 detox@12 到 detox@13 的重大变化吗?【英文标题】:Do you know the breaking changes from detox@12 to detox@13? 【发布时间】:2019-11-28 05:12:42 【问题描述】:

Migration guide 目前坚持使用 12.7.0,而最后一个版本是 13.2.0,并且(在 semver 之后)引入了重大更改。

就我自己而言,我更新到了 13.1(之前,也更新到了 12.11),但我遇到了超时(在初始化后使用 xxx is not defined),应用程序启动但立即关闭。

我尝试使用 config.json 作为开玩笑的例子,再次清理和构建 detox 缓存,清理我的 ios 构建文件夹,从 10.1 到 10.2.1,重新安装最新的 applesimutils,没有任何变化。


依赖关系:

开玩笑:14.x 反应原生:0.59.8 排毒:13.1

我的 package.json:


  "scripts": 
    "start:e2e": "REACT_NATIVE_FLAVOR=E2E npm run -s start:clean",
    "build:ios:cmd": "cd ios && export RCT_NO_LAUNCH_PACKAGER=1 && xcodebuild -workspace Coorpacademy.xcworkspace -scheme Coorpacademy -derivedDataPath build",
    "build:iphonesimulator:debug": "REACT_NATIVE_FLAVOR=E2E npm run build:ios:cmd -- -configuration Debug -sdk iphonesimulator | xcpretty",
    "prebuild:iphonesimulator:release": "REACT_NATIVE_FLAVOR=E2E npm run -s generate:bundle:ios",
    "build:iphonesimulator:release": "REACT_NATIVE_FLAVOR=E2E npm run build:ios:cmd -- -configuration Release -sdk iphonesimulator | xcpretty",
    "build:androidemulator:debug": "cd android && export REACT_NATIVE_FLAVOR=E2E && ./gradlew assembleDebug assembleAndroidTest  -DtestBuildType=debug && cd ..",
    "build:androidemulator:release": "cd android && export REACT_NATIVE_FLAVOR=E2E && ./gradlew assembleRelease assembleAndroidTest  -DtestBuildType=release && cd ..",
    "test:end2end:ios:debug": "npm run test:end2end:ios:debug:build && npm run test:end2end:ios:debug:test",
    "test:end2end:ios:debug:build": "detox build --configuration=ios.simulator.debug",
    "test:end2end:ios:debug:test": "detox test --configuration=ios.simulator.debug",
    "test:end2end:ios:release": "npm run test:end2end:ios:release:build && npm run test:end2end:ios:release:test",
    "test:end2end:ios:release:build": "detox build --configuration=ios.simulator.release",
    "test:end2end:ios:release:test": "detox test --configuration=ios.simulator.release",
    "test:end2end:android:debug": "npm run test:end2end:android:debug:build && npm run test:end2end:android:debug:test",
    "test:end2end:android:debug:build": "detox build --configuration=android.emulator.debug",
    "test:end2end:android:debug:test": "detox test --configuration=android.emulator.debug",
    "test:end2end:android:release": "npm run test:end2end:android:release:build && npm run test:end2end:android:release:test",
    "test:end2end:android:release:build": "detox build --configuration=android.emulator.release",
    "test:end2end:android:release:test": "detox test --configuration=android.emulator.release",
  ,
  "detox": 
    "test-runner": "jest",
    "runner-config": "jest.config.e2e.js",
    "configurations": 
      "ios.simulator.debug": 
        "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/Coorpacademy.app",
        "build": "npm run build:iphonesimulator:debug",
        "type": "ios.simulator",
        "name": "iPhone 6"
      ,
      "ios.simulator.release": 
        "binaryPath": "ios/build/Build/Products/Release-iphonesimulator/Coorpacademy.app",
        "build": "npm run build:iphonesimulator:release",
        "type": "ios.simulator",
        "name": "iPhone 6"
      ,
      "android.emulator.debug": 
        "binaryPath": "android/app/build/outputs/apk/debug/Coorpacademy-debug.apk",
        "build": "npm run build:androidemulator:debug",
        "type": "android.emulator",
        "name": "Nexus_5X_API_19"
      ,
      "android.emulator.release": 
        "binaryPath": "android/app/build/outputs/apk/release/Coorpacademy-release.apk",
        "build": "npm run build:androidemulator:release",
        "type": "android.emulator",
        "name": "Nexus_5X_API_19"
      
    
  

我的地铁配置:

const createBlacklist = require('metro-config/src/defaults/blacklist');

const REACT_NATIVE_FLAVOR = process.env;

module.exports = 
  resolver: 
    sourceExts: REACT_NATIVE_FLAVOR === 'E2E' ? ['e2e.js', 'js'] : ['js'],
    blacklistRE: (() => 
      if (REACT_NATIVE_FLAVOR === 'STORYBOOK') 
        // this is to have fixtures embedded in storybook app
        return createBlacklist([]);
      
    )()
  ,
  transformer: 
    getTransformOptions: () => (
      transform: 
        experimentalImportSupport: false,
        inlineRequires: false
      
    )
  
;

我的笑话配置:

module.exports = 
  testEnvironment: 'node',
  moduleFileExtensions: ['unit.js', 'unit.json', 'ios.js', 'android.js', 'js', 'json'],
  setupFilesAfterEnv: ['./__e2e__/init.js'],
  reporters: ['detox/runners/jest/streamlineReporter'],
  bail: true,
  verbose: true
;

还有我的初始化文件:

import detox from 'detox';
import adapter from 'detox/runners/jest/adapter';
import specReporter from 'detox/runners/jest/specReporter';

import json from '../package';

const config = json.detox;

jest.setTimeout(120000);
// $FlowFixMe jest flow type is incomplete
jasmine.getEnv().addReporter(adapter);
// $FlowFixMe jest flow type is incomplete
jasmine.getEnv().addReporter(specReporter);

beforeAll(async () => 
  await detox.init(config);
  global.weExpect = expect;
);

beforeEach(async function() 
  await adapter.beforeEach();
);

afterAll(async () => 
  await adapter.afterAll();
  await detox.cleanup();
);

【问题讨论】:

【参考方案1】:

正如在某个问题上所讨论的,没有需要输入迁移指南的重大更改。输入了重大更改,并且有可能破坏许多工作环境,因此我认为升级主要版本更安全,并且减少用户被破坏的风险。为了说明这一点,我更新了迁移指南的介绍部分以说明这一点。

13.1 中引入了一项更改,导致某些 iOS 应用出现问题。这已在 13.2 中修复,因此请升级到该版本,看看它是否能解决您的问题。如果没有,请打开错误报告并提供所有必需的信息。

【讨论】:

以上是关于你知道从 detox@12 到 detox@13 的重大变化吗?的主要内容,如果未能解决你的问题,请参考以下文章

从虚拟化到私有云 你需要知道的上云方法论

零基础程序员自学编程的6种方法,你知道吗?

Python实战案例汇总,带你轻松从入门到实战

程序人生从外包到大厂,你知道我这一个月是怎么过的吗?

你知道Spring是怎么将AOP应用到Bean的生命周期中的吗?

你知道Spring是怎么将AOP应用到Bean的生命周期中的吗?