Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48986

TypeError: ionRouterOutlet.commit is not a function

$
0
0

Hi,

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 />
    </Router>
  );
  const postBtn = await getByTestId("posts"); // It's not able to find element with posts
  fireEvent.click(postBtn);
  
});

and In IonTabButton

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

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

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 48986

Trending Articles



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