我目前正在为现有项目设置 Detox 并遇到障碍。
我正在使用 Detox + Jest 并收到错误消息
[Client.js/PENDING_REQUESTS] App has not responded to the network requests below:
(id = 1) invoke: {"target":{"type":"Invocation","value":{"target":{"type":"EarlGrey","value":"instance"},"method":"detox_selectElementWithMatcher:","args":[{"type":
"Invocation","value":{"target":{"type":"Class","value":"GREYMatchers"},"method":"detoxMatcherForText:","args":[{"type":"NSString","value":"hello"}]}}]}},"method":"assertWithMatcher:","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"GREYMatchers"},"method":"matcherForNotNil","args":[]}}]}
That might be the reason why the test "Login Screen should have login fields" has timed out.
Run Code Online (Sandbox Code Playgroud)
我的设置是
detox@14.9.1
jest-circus@24.9.0
jest@24.9.0
node@13.3.0
react-native@0.61.5
xcode@11.3
我的 package.json 有
"detox": {
"configurations": {
"ios.sim.debug": {
"binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/<project>.app",
"build": "xcodebuild -workspace ios/<project>.xcworkspace -scheme <project> -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
"type": "ios.simulator",
"device": {
"type": "iPhone X",
"id": "D6C93AA8-0002-4286-BEFA-AA1CC2BB5951", …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用反应导航为应用程序编写测试,但遇到了正确读取路线和参数的问题。
我收到一个错误
类型错误:无法读取未定义的属性“params”
在const [leadId] = useState(route.params.leadId);
我的组件看起来像
export default function AComponent() {
const route = useRoute();
const navigation = useNavigation();
const dispatch = useDispatch();
const [leadId] = useState(route.params.leadId);
}
Run Code Online (Sandbox Code Playgroud)
我已尝试遵循https://callstack.github.io/react-native-testing-library/docs/react-navigation/Warning: React.createElement: type is invalid但在包装组件时收到了。
我的测试看起来像
import React from 'react';
import { Provider } from 'react-redux';
import { NavigationContainer } from '@react-navigation/native';
import { render, fireEvent, cleanup } from 'react-native-testing-library';
import configureMockStore from 'redux-mock-store';
import AComponent from 'components/contact/AComponent';
const mockStore = configureMockStore([]);
describe('<AComponent />', () => …Run Code Online (Sandbox Code Playgroud) javascript jestjs react-native react-navigation react-native-testing-library