Skip to content

How to use test.mock if result is a Union type #117

Description

@fernandohenriques

In this example in my code, the query returns always empty:

it('Should return store by id', () => {
   const query = `
     query($id: ID, $slug: String) {
       store(id: $id, slug: $slug) {
         ... on Store {
           id
           name
           slug
         }
       }
     }
   `;

   const fixture = {
     data: {
       store: {
         id: '1',
         name: 'AnyoneStore'
       }
     }
   };

   const variables = {
     id: "1"
   };

   const { data: { store } } = tester.mock({ query, fixture, variables });

  // store
 / / {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions