vendredi 11 septembre 2020

How can I test for rendering errors in react native (Using Jest + React Native Testing Library)?

Example, let's say I have this component:

import React from "react";
import { StyleSheet, Text, View } from "react-native";

export default function Home(props) {

  return (
    <View testID="main_view" style={styles.container}>
      Open up App.js to start working on your app!
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center",
  },
});

When I try to navigate to this screen, it will fail, because there's text outside of a wrapper. How can I have jest + RNTL to throw an error in this case?

Aucun commentaire:

Enregistrer un commentaire