Skip to content

Missing MockLink (or similar) in vue-apollo #1003

@cilice

Description

@cilice

Is your feature request related to a problem? Please describe.
Apollo for React has https://www.apollographql.com/docs/react/development-testing/testing/, which implements a MockLink in here: https://github.com/apollographql/apollo-client/blob/master/src/utilities/testing/mocking/MockedProvider.tsx (this is the link to the apollo v3 version, but it's similar for v2)

Adding that unfortunately doesn't work nicely since it has a dependency on React.

Describe the solution you'd like

I'd like to add an "official" MockLink in vue-apollo, or a way to create a testing client which you can use.

Something like import { createMockClient } from '@vue/apollo-testing' would be ideal.

Describe alternatives you've considered
I've copied the code from MockLink into an own package so it doesn't depend on React, which works well internally at @sumcumo. Additionally, there is also https://github.com/Mike-Gibson/mock-apollo-client/, which works in a different way than the MockLink.
Suggesting stubbing apollo in tests is in my opinion a bad practise, see https://kentcdodds.com/blog/stop-mocking-fetch

This applies for both, v3 and v4.

I'm happy to work on it to provide a PR for both, v3 and v4, as well, if you think that it would belong to this library.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions