TypeError: ionRouterOutlet.commit is not a function

Viewed 152

I'm writing test cases for my ionic react application using react-testing-library. I'm facing two issues

1) I'm trying to write a test case for a button click which redirects to another route. below is the test snippet I'm using :

test("redirect from posts to lesson", async () => {

    const { baseElement, getByTestId } = render(<App />);
    const postBtn = await getByTestId("go-to-lessons");
    fireEvent.click(postBtn);
});

This test snippet giving me:

TypeError: ionRouterOutlet.commit is not a function

2) I'm using the ionic tabs template and I want to test tab changing but I'm not able to add data-testid props on IonTabButton so getByTestId is giving error, is there any other way of getting IonTabButton in test cases?

Thanks in Advance

0 Answers
Related