relay-workshop icon indicating copy to clipboard operation
relay-workshop copied to clipboard

Solve relay's environment mock cache

Open Streeterxs opened this issue 5 years ago • 0 comments

Overview

We use the same relay's Environment for each test case, this breaks for the new relay 11 environment cache

Solution

We need a way to solve forever our relay's Environment mock, independant for each test case

Step-by-step

create a const using createMockEnvironment() function and pass it to the withProviders object parameter

  const environment = createMockEnvironment();
  const Root = withProviders({
    environment,
  });

change all use of the old Environment to the new environment const: from:

  Environment.mock.resolveMostRecentOperation((operation) =>
    MockPayloadGenerator.generate(operation, customMockResolvers),
  );

to:

  environment.mock.resolveMostRecentOperation((operation) =>
    MockPayloadGenerator.generate(operation, customMockResolvers),
  );

Environment -> environment

Streeterxs avatar Mar 01 '21 21:03 Streeterxs