Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

215
Views
React native Jest- navigation.setOptions

I'm not able to test a react-native screen that should render a headerRight icon on navigation setOptions is being called in the constructor I have a react native code for which I have

this.props.navigation.setOptions({
      title: this.props.t("Team"),
      headerRight: () => {
        console.log("header right>>")
        return(
        <View style={{ flex: 1, flexDirection: "row", paddingRight: 10 }}>
          <HeaderIcon
            testID= {"search-icon"}
            onPress={() => {
              this.setState({
                showSearch: true,
              });
            }}
            iconName={"search"}
          />
          <HeaderIcon
            onPress={() => {
              props.navigation.navigate("AccessManagerNewUser");
            }}
            iconName={"person-add"}
          />
        </View>
      )},
    });

My class-based component is setting headerRight with this navigation function. My Jest test has the below as navigation props.

 navigation: {
    addListener: jest.fn(),
    setOptions: () => {},
    navigate: jest.fn(),
  },

This is never calling the headerRight method when I'm running my tests

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!