Skip to content

MockedProvider - mutation errors are not passed to the component #4283

@albertortizn26

Description

@albertortizn26

Hi,
I have been facing a problem mocking data with MockedProvider.
With queries all works as expected, when I mock success and errors, the problem comes with mutations, success are ok but when I try to mock an error it is not passed to my component in the render function, instead an Error is thrown.

Test:

 const mocks = [
        {
            request: {
                query: MY_MUTATION,
                variables: {
                    userId: 'error'
                },
            },
            error: new Error('boom!')
        }
];

it('my test that should pass', () => {

        const wrapper = mount(
            <MockedProvider mocks={mocks}>
                <MyComponent ... />
            </MockedProvider>
        );
...

Component:

 <Mutation mutation={MY_MUTATION} >
                {(cancelMandate, {loading, error}) => (
...

When I run the test it just throw the exception but in a live environment it is passed to the component!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions