Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testcases are failing from 1.5.7 #90

Open
sureshacct opened this issue May 18, 2020 · 2 comments
Open

Testcases are failing from 1.5.7 #90

sureshacct opened this issue May 18, 2020 · 2 comments

Comments

@sureshacct
Copy link

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

@marcin-piela
Copy link
Owner

Hi @sureshacct

I can't see any interceptors here, could you provide an example in codesandbox?

@sureshacct
Copy link
Author

Hi @marcin-piela

I have added a sample project in the below codesandbox.
https://codesandbox.io/s/agitated-shaw-jcw63

Added a hook useFetchResource.ts and its associated test file along with interceptor. The test passes until 1.5.6 version but post that its failing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants