testing-library / react-testing-library

🐐 Simple and complete React DOM testing utilities that encourage good testing practices.
https://testing-library.com/react
MIT License
18.84k stars 1.09k forks source link

Regression: Types of property `hydrate` are incompatible in `renderHook` options #1312

Closed samettttt closed 2 months ago

samettttt commented 2 months ago

Relevant code or config:

import { RenderHookOptions, renderHook } from '@testing-library/react';

export const renderHookHelper = <TProps, TResult>(
    callback: (props: TProps) => TResult,
    options: RenderHookOptions<TProps> = {},
) => {
    // ...
    // bunch of code
    // ...

    return renderHook(callback, { ...options });
};

What you did:

We use the RenderHookOptions type for a parameter in a helper function where we call renderHook.

What happened:

Screenshot 2024-04-24 at 20 49 01

Reproduction:

https://stackblitz.com/edit/rtl-template-22bvkk?file=src%2FApp.test.tsx

Problem description:

We can't simply use the RenderHookOptions type in our helper function. There are workaround to this problem but I thought that maybe this change was not intentional.