排毒测试失败,id 良好

时间:2021-03-30 08:39:05

标签: typescript react-native native-base detox

我已经在我的组件上定义了 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

0 个答案:

没有答案