relay-workshop
relay-workshop copied to clipboard
Solve relay's environment mock cache
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