TypeError: ionRouterOutlet.commit is not a function


I’m writing test cases for react ionic app ( using tab template ). I want to test when I click on IonTabButton it should redirect to the correct route. How can I achieve this? Below is the code I’m trying

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

  const history = createMemoryHistory()
  const { baseElement, getByTestId } = render(
    <Router history={history}>
      <App />
  const postBtn = await getByTestId("posts"); // It's not able to find element with posts

and In IonTabButton

<IonTabButton data-testid="posts" tab="posts" href="/posts">
     src="/assets/icon/active/category_show.png" /> 

How can I add testid in IonTab Button

And in another test which is on button component (HTML component), in this test case getByTestId is working but click on it causing below error:

TypeError: ionRouterOutlet.commit is not a function