【发布时间】: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();
});
【问题讨论】:
标签: react-native jestjs detox