Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Detox tests failed with good id

$
0
0

I have defined testID on my components to implement detox tests, but some tests failed.

I want to test if the components exist or if they are visible.

My first test work correctly, but the three other doesn't work and returned a failure

My screen :

//...var i = -1const MemoizedListeMissions = React.memo(ListeMissions, (prevProps, nextProps) => {    if (_.isEqual(prevProps.missions, nextProps.missions)) {        return true; // props are equal    } else {        if (nextProps.error === true) {            return true        }        return false; // props are not equal -> update the component    }})const ListeMissions = ({ missions }: Crops) => {    return <List testID="missionsList" dataArray={missions} keyExtractor={mission => mission.id} renderRow={(mission: MissionMobile) =><View testID={`test${i}`} style={styles.missionCardView}><Card style={styles.missionCard}><CardItem style={styles.cardHeaderStyle} header>                    {cardHeader(mission)}</CardItem><CardSwiper mission={mission} /></Card></View>    }></List>}const CardSwiper = ({ mission }: Props) => {//...return (<CardItem footer style={styles.footerStyle}><View style={styles.prestaView}>                {LogBox.ignoreAllLogs(true)}<DeckSwiper                    testID={`prestationSwiper${i}`}                    key={uniqueId()}                    dataSource={mission.listePrestation}                    renderItem={(prestation: PrestationListMobile) =><Card style={styles.cardsStyle}><CardItem style={styles.cardsItemStyle}><View><TouchableOpacity testID={`touchablePrestation${i++}`} onPress={() => onAccessPrestation ( mission.id, prestation.idPrestation )}>                                        {console.log(`touchablePrestation${i}`)}<Text>{prestation.idPrestation}</Text>                                        {etatPrest(prestation.etatPrestation, prestation.typePrestation)}<Text style={{ marginTop: 5 }}>{labelTypePrestation(prestation.typePrestation)}</Text>                                        {nomAssure(prestation.assure)}                                        {adressePresta(prestation.lieu)}                                        {checkPrestaState(prestation.etatPrestation, prestation.idPrestation)}</TouchableOpacity></View></CardItem></Card>                    } /></View></CardItem>    )}const cardsScreen = () => {    const { missionsData, error, isError } = useMissionsFetcher()    return (<Container testID="cardsScreen"><MissionHeader type='missionsCard' /><MemoizedListeMissions                //@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 mission card', async () => {    expect(element(by.id("test0"))).toBeVisible()  })  test('should have a prestation', async () => {    await waitFor(element(by.id("prestationSwiper"))).toExist().withTimeout(5000)  })  test('should be touchable', async () => {    await expect(element(by.id("touchablePrestation0"))).toExist()  })});

Error :

● full › should have a prestation

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  40 |   })  41 |   test('should have mission card', async () => {> 42 |     expect(element(by.id("test0"))).toBeVisible()     |                                     ^  43 |   })  44 |     45 |   test('should have a prestation', async () => {  at Object.<anonymous> (01-login.e2e.ts:42:37)

● full › should have a prestation

DetoxRuntimeError: Test Failed: 5.0sec timeout expired without matching of given matcher: not null  44 |     45 |   test('should have a prestation', async () => {> 46 |     await waitFor(element(by.id("prestationSwiper"))).toExist().withTimeout(5000)     |                                                                 ^  47 |   })  48 |   test('should be touchable', async () => {  49 |     await expect(element(by.id("touchablePrestation0"))).toExist()  at Object.<anonymous> (01-login.e2e.ts:46:65)

● full › should be touchable

DetoxRuntimeError: Test Failed: 'not null' doesn't match the selected view.Expected: not null     Got: null  47 |   })  48 |   test('should be touchable', async () => {> 49 |     await expect(element(by.id("touchablePrestation0"))).toExist()     |                                                          ^  50 |   })  51 | });  52 |
detox[3367] ERROR: [cli.js] Command failed: jest --config e2e/config.json --testNamePattern '^((?!:ios:).)*$' --maxWorkers 1 e2e

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>