如何解决排毒测试失败,id 良好
我已经在我的组件上定义了 testID 来实现排毒测试,但有些测试失败了。
我想测试组件是否存在或者它们是否可见。
我的第一个测试工作正常,但列表中的第二个不起作用并返回失败
我的屏幕:
//...
var i = -1
const ListeMissions = ({ missions }: Crops) => {
return <List testID="missionsList" dataArray={missions} keyExtractor={mission => mission.id} renderRow={(mission: MissionMobile) =>
<Text testID={`test${i++}`}> This is text</View>
}>
</List>
}
const cardsScreen = () => {
const { missionsData,error,isError } = useMissionsFetcher()
return (
<Container testID="cardsScreen">
<MissionHeader type='missionsCard' />
<ListeMissions
//@ts-ignore
missions={missionsData}
error={isError} />
</Container>
)
}
tests.e2e.ts :
import { expect } from 'detox'
describe('full test',() => {
///////////////////////// Work
test('should have a missions list',async () => {
await expect(element(by.id("missionsList"))).toBeVisible()
})
///////////////////////// Doesn't work
test('should have a test text',async () => {
await expect(element(by.id("test0"))).toBeVisible()
})
});
错误:
● full › 应该有测试文本
DetoxRuntimeError: Test Failed: 'at least 75 percent of the view's area is displayed to the user.' doesn't match the selected view.
Expected: at least 75 percent of the view's area is displayed to the user.
Got: null
41 |
42 | test('should have a test text',async () => {
> 43 | await expect(element(by.id("test0"))).toBeVisible()
| ^
44 | })
at Object.<anonymous> (01-login.e2e.ts:43:47)
detox[4709] ERROR: [cli.js] Command failed: jest --config e2e/config.json --testNamePattern '^((?!:ios:).)*$' --maxWorkers 1 e2e
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。