TanStackT
TanStack15mo ago
5 replies
moderate-tomato

rerender test

Hey there, currently the tanstack router does not seem to support testing rerender of hooks from:
import { renderHook } from '@testing-library/react'

I made a PR/fix https://github.com/TanStack/router/pull/2796

What is the correct process to get it approved?

We have a repo with over 300000 lines of code and heavily depend on our unit/integration tests to pass, our hooks have some rather simple but powerful rerender tests since it can prove no state changes are done as part of a rerender - but tanstack router seems to block that untill this PR is merged...

it("should not trigger state change on rerender", () => {
    const { result, rerender } = renderHook(() => {
      return useYourHookToTest();
    });

    const initial = result.current;

    rerender();

    const updated = result.current;

    expect(updated).toBeTruthy();
    expect(updated).toBe(initial);
  }); 
GitHub
This changes so Tanstack router will support rerenders in tests using the renderHooks from testing library.
import { renderHook } from '@testing-library/react'
We heavily depend on ...
Allow rerender by mta-trackunit · Pull Request #2796 · TanStack/rou...
Was this page helpful?