Skip to content

Testcases are failing from 1.5.7 #90

Open
@sureshacct

Description

@sureshacct

Hello

I am using react-testing-library to test my network components and it was working fine until 1.5.6 version. After upgrading to 1.5.7 I am observing failures

Sample testcase:

it('fetches resource and returns proper data on success', async () => {
        const id = '12345';
        const type = 'text';
        const fetchFunction: () => Promise<QueryResponse> = async () => ({
            error: false,
            status: 200,
            payload: successResponse,
        });
        const Client = createClient({
            params: { host: 'https://mockHost', basePath: 'mockPath', defaultQueryParams: {} },
        });
        Client.query = fetchFunction;

        const wrapper = ({ children }: any): any => (
            <ClientContextProvider client={Client}>{children}</ClientContextProvider>
        );

        jest.useFakeTimers();

        const { result } = renderHook<void, any>(
            () => useFetchQuery(id, type),
            {
                wrapper: wrapper,
            },
        );
        expect(result.current.loading).toEqual(true);
        expect(result.current.error).toEqual(false);
        act(() => {
            jest.runAllTimers();
        });

        expect(result.current.loading).toEqual(false);
        expect(result.current.error).toEqual(false);     
    });

Issue: Looks like there is some issue with the request interceptor. There is null response from interceptor

I am stuck with 1.5.6 release but i have to upgrade it to latest version to use some of its features

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions