- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在为现有项目设置 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.
"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",
"os": "iOS 10.3.1"
}
},
"ios.sim.iphone7": {
"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 7",
"id": "E999FB34-1D9E-46DE-94EF-5181489D0D3E"
}
}
},
"test-runner": "jest",
"runner-config": "e2e/config.json"
},
"jest": {
"setupFiles": [
"jest-plugin-context/setup",
"<rootDir>/test/setup.js"
],
"preset": "react-native",
"transform": {
"^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js"
}
}
const detox = require('detox');
const config = require('../package.json').detox;
const adapter = require('detox/runners/jest/adapter');
const specReporter = require('detox/runners/jest/specReporter');
const assignReporter = require('detox/runners/jest/assignReporter');
// Set the default timeout
jest.setTimeout(60000);
detoxCircus.getEnv().addEventsListener(adapter);
detoxCircus.getEnv().addEventsListener(specReporter);
detoxCircus.getEnv().addEventsListener(assignReporter);
beforeAll(async () => {
console.log('start init');
await detox.init(config, { launchApp: false });
console.log('end init');
});
beforeEach(async () => {
console.log('before each in init.js');
await adapter.beforeEach();
});
afterAll(async () => {
await adapter.afterAll();
await detox.cleanup();
});
describe('Login Screen', () => {
it('should have login fields', async () => {
console.log('in unit test');
await expect(element(by.text('hello'))).toExist();
});
});
detox[76606] INFO: [test.js] configuration="ios.sim.debug" loglevel="trace" debugSynchronization=200 reportSpecs=true DETOX_START_TIMESTAMP=1576279006528 node_modules/.bin/jest --config e2e/config.json '--testNamePattern=^((?!:android:).)*$' --maxWorkers 1 --forceExit "e2e"
watchman warning: opendir(/Users/<user>/code/<project>/node_modules/@babel/.plugin-syntax-jsx.MODULES/@babel/core/node_modules/.bin) -> Operation not permitted. Marking this portion of the tree deleted
To clear this warning, run:
`watchman watch-del /Users/<user>/code/<project> ; watchman watch-project /Users/<user>/code/<project>`
console.log e2e/init.js:15
start init
detox[76607] INFO: [DetoxServer.js] server listening on localhost:52295...
detox[76607] DEBUG: [AsyncWebSocket.js/WEBSOCKET_OPEN] opened web socket to: ws://localhost:52295
detox[76607] TRACE: [AsyncWebSocket.js/WEBSOCKET_SEND] {"type":"login","params":{"sessionId":"7b41bb7d-70a4-0ea7-e0a8-604f30dbd51d","role":"tester"},"messageId":0}
detox[76607] DEBUG: [DetoxServer.js/LOGIN] role=tester, sessionId=7b41bb7d-70a4-0ea7-e0a8-604f30dbd51d
detox[76607] DEBUG: [DetoxServer.js/LOGIN_SUCCESS] role=tester, sessionId=7b41bb7d-70a4-0ea7-e0a8-604f30dbd51d
detox[76607] TRACE: [AsyncWebSocket.js/WEBSOCKET_MESSAGE] {"type":"loginSuccess","params":{"sessionId":"7b41bb7d-70a4-0ea7-e0a8-604f30dbd51d","role":"tester"},"messag
eId":0}
detox[76607] DEBUG: [exec.js/EXEC_CMD, #0] applesimutils --list --byId D6C93AA8-0002-4286-BEFA-AA1CC2BB5951 --byType "iPhone X"
detox[76607] TRACE: [exec.js/EXEC_SUCCESS, #0] [
{
"deviceType" : {
"name" : "iPhone X",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone X.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-X"
},
"state" : "Booted",
"isAvailable" : true,
"name" : "iPhone X",
"udid" : "D6C93AA8-0002-4286-BEFA-AA1CC2BB5951",
"os" : {
"buildversion" : "17C45",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime",
"isAvailable" : true,
"name" : "iOS 13.3",
"identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-13-3",
"version" : "13.3"
}
}
]
detox[76607] DEBUG: [exec.js/EXEC_CMD, #1] applesimutils --list --byId D6C93AA8-0002-4286-BEFA-AA1CC2BB5951 --maxResults 1
detox[76607] TRACE: [exec.js/EXEC_SUCCESS, #1] [
{
"deviceType" : {
"name" : "iPhone X",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone X.simdevicetype",
"identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-X"
},
"state" : "Booted",
"isAvailable" : true,
"name" : "iPhone X",
"udid" : "D6C93AA8-0002-4286-BEFA-AA1CC2BB5951",
"os" : {
"buildversion" : "17C45",
"bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime",
"isAvailable" : true,
"name" : "iOS 13.3",
"identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-13-3",
"version" : "13.3"
}
}
]
detox[76607] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onBootDevice({ coldBoot: false, deviceId: 'D6C93AA8-0002-4286-BEFA-AA1CC2BB5951' })
detox[76607] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onBeforeUninstallApp({
deviceId: 'D6C93AA8-0002-4286-BEFA-AA1CC2BB5951',
bundleId: '<project>'
})
detox[76607] DEBUG: [exec.js/EXEC_CMD, #2] /usr/bin/xcrun simctl uninstall D6C93AA8-0002-4286-BEFA-AA1CC2BB5951 <project>
detox[76607] DEBUG: [exec.js/EXEC_TRY, #2] Uninstalling <project>...
detox[76607] TRACE: [exec.js/EXEC_SUCCESS, #2]
detox[76607] DEBUG: [exec.js/EXEC_SUCCESS, #2] <project> uninstalled
detox[76607] DEBUG: [exec.js/EXEC_CMD, #3] /usr/bin/xcrun simctl install D6C93AA8-0002-4286-BEFA-AA1CC2BB5951 "/Users/<user>/code/<project>/ios/build/Buil
d/Products/Debug-iphonesimulator/<project>.app"
detox[76607] DEBUG: [exec.js/EXEC_TRY, #3] Installing /Users/<user>/code/<project>/ios/build/Build/Products/Debug-iphonesimulator/<project>.app...
detox[76607] TRACE: [exec.js/EXEC_SUCCESS, #3]
detox[76607] DEBUG: [exec.js/EXEC_SUCCESS, #3] /Users/<user>/code/<project>/ios/build/Build/Products/Debug-iphonesimulator/<project>.app installed
detox[76607] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onBeforeAll()
console.log e2e/init.js:18
end init
Login Screen: should have login fields
console.log e2e/init.js:22
before each in init.js
detox[76607] INFO: Login Screen assigned to D6C93AA8-0002-4286-BEFA-AA1CC2BB5951 {"type":"iPhone X","id":"D6C93AA8-0002-4286-BEFA-AA1CC2BB5951"}
detox[76607] TRACE: [Detox.js/DETOX_BEFORE_EACH] running test: "Login Screen should have login fields"
detox[76607] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onBeforeEach({
title: 'should have login fields',
fullName: 'Login Screen should have login fields',
status: 'running'
})
console.log e2e/loginScreen.spec.js:7
in unit test
detox[76607] TRACE: [AsyncWebSocket.js/WEBSOCKET_SEND] {"type":"invoke","params":{"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":[]}}]},"messageId":1}
detox[76607] TRACE: [DetoxServer.js/MESSAGE] role=tester action=invoke (sessionId=7b41bb7d-70a4-0ea7-e0a8-604f30dbd51d)
detox[76607] DEBUG: [DetoxServer.js/CANNOT_FORWARD] role=testee not connected, cannot fw action (sessionId=7b41bb7d-70a4-0ea7-e0a8-604f30dbd51d)
detox[76607] TRACE: [AsyncWebSocket.js/WEBSOCKET_SEND] {"type":"currentStatus","params":{},"messageId":2}
detox[76607] TRACE: [DetoxServer.js/MESSAGE] role=tester action=currentStatus (sessionId=7b41bb7d-70a4-0ea7-e0a8-604f30dbd51d)
detox[76607] DEBUG: [DetoxServer.js/CANNOT_FORWARD] role=testee not connected, cannot fw action (sessionId=7b41bb7d-70a4-0ea7-e0a8-604f30dbd51d)
Login Screen: should have login fields [FAIL]
detox[76607] TRACE: [Detox.js/DETOX_AFTER_EACH] failed test: "Login Screen should have login fields"
detox[76607] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onAfterEach({
title: 'should have login fields',
fullName: 'Login Screen should have login fields',
status: 'failed',
timedOut: true
})
detox[76607] WARN: [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.
detox[76607] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onAfterAll()
detox[76607] DEBUG: [DetoxServer.js/DISCONNECT] role=tester, sessionId=7b41bb7d-70a4-0ea7-e0a8-604f30dbd51d
detox[76607] DEBUG: [DetoxServer.js/WS_CLOSE] Detox server connections terminated gracefully
FAIL e2e/loginScreen.spec.js (64.646s)
Login Screen
✕ should have login fields (60003ms)
● Login Screen › should have login fields
thrown: "Exceeded timeout of 60000ms for a test.
Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."
4 | });
5 |
> 6 | it('should have login fields', async () => {
| ^
7 | console.log('in unit test');
8 | await expect(element(by.text('hello'))).toExist();
9 | // await expect(element(by.id('loginScreen-username'))).toBeVisible().withTimeout(60000);
at it (loginScreen.spec.js:6:3)
at Object.describe (loginScreen.spec.js:1:1)
最佳答案
我遇到了同样的问题并设法通过从 Debug
切换来使其工作至 Release
模拟器。
"ios.sim.release": {
"binaryPath": "ios/build/Build/Products/Release-iphonesimulator/<project>.app",
"build": "xcodebuild -workspace ios/<project>.xcworkspace -scheme <project> -configuration Release -sdk iphonesimulator -derivedDataPath ios/build",
"type": "ios.simulator",
"device": {
"type": "iPhone X",
"id": "D6C93AA8-0002-4286-BEFA-AA1CC2BB5951",
"os": "iOS 10.3.1"
}
},
关于react-native - Detox + Jest - 应用没有响应下面的网络请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59329559/
我正在为我的 react 项目编写单元测试用例,并使用 Jest 和 enzyme 来编写测试用例。我已阅读 Jest 文档 https://jestjs.io/docs/en/jest-object
运行测试时出现以下错误: 无法从“jest-expect.js”中找到模块“jest-matchers” at Resolver.resolveModule (node_modules/jest-
如何使用 jest.run() 或 jest.runCLI() 以编程方式运行所有测试?我应该用什么作为论据? 我试图找到有关它们的文档但失败了。 如果上述函数不起作用,如果我想以编程方式运行 jes
用 Jest 和 enzyme 测试 react 和 typescript ,我如何模拟这个 ExpectsVideo 函数,以便我可以根据我的测试用例场景定义它是否返回 true 或 false j
用 Jest 和 enzyme 测试 react 和 typescript ,我如何模拟这个 ExpectsVideo 函数,以便我可以根据我的测试用例场景定义它是否返回 true 或 false j
我正在使用以下 jest.unittest.json 文件(通过 jest --config 选项使用): { "bail": false, "verbose": true, "trans
我跑npm init npm i -D jest像这样 tutorial 运行推荐 nmp test 后出现此错误 这不是生物.js 或生物.test.js 的错误,因为没有发生此文件错误。我怎样才能
我有一个 Mongoose 模型: var mongoose = require("mongoose"); var transactionSchema = mongoose.Schema({ ca
我在我的角度项目中进行了 Jest 测试。 我有一个 package.json 文件指定了我想用来运行测试的 jest 版本。该文件包括: "@types/jest": "^24.0.18", "je
我正在尝试使用 jest 编写单元测试用例,并且需要模拟以下模式。我收到 TypeError: is not a constructor。 用例:我的用例如下所述 我的组件.js : import
所以我正在使用 jest测试我的 node.js 应用程序,测试完成得很好,但我从 jest 收到一条关于打开句柄的消息。任何见解? jest --detectOpenHandles 通过 src/l
我正在使用 Babel Jest 来转换我的代码以进行测试。 我不知道如何使用相对于项目根目录的路径。 例如,如果我在一个测试文件中导入一个模块:/imports/ui/myModule Jest 抛
我正在致力于更新 Express 微服务的测试。对于某些目录(即我们的 /utils 文件夹),我编写了大量测试,显示覆盖率达到 80-90%。在/routes目录下,有0个测试,但显示100%。 总
我收到以下错误: import React from 'react'; ^^^^^^ SyntaxError: Unexpected token import 原因是一些模块/s在npm中发布时没有编
我正在创建一个 Jest 测试来测试是否记录了用于 superFetch 函数错误处理的指标。我的方法是为 retryFetch 创建一个模拟函数并返回一个 Promise 拒绝事件。我希望它能进入
我正在设置一些新的配置来开 Jest ,我忽略了一些文件,比如 *.stories.js,但是当我使用 *.js.snap 或 *.snap,这个 Jest 不太行。 我正在使用 react-scri
PS E:\react\Code\UI> yarn 测试 yarn 运行 v1.17.3$开 Jest 失败 src/App.test.js ● 测试套件运行失败 Jest encountered a
我是开 Jest 测试的新手,我写了下面的测试。我 Jest mock 了一个函数并将其作为参数传递。但是当运行测试时,在日志中我可以看到函数 onSuccess 被调用。但 expect 失败并出现
我是测试新手。我正在使用 JEST 来测试我的 nodejs API。当我在一个文件中编写所有测试时,它可以正常运行,没有任何错误,但是当我分离它时,它给我的端口已经在使用中。至于每个文件,它运行不同
我正在编写一个 Jest 模拟,但是在模拟本身之外定义一个模拟函数时我似乎遇到了问题。 我有一个类: myClass.js class MyClass { constructor(name) {
我是一名优秀的程序员,十分优秀!