Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are there any tests written for these examples ? #114

Open
maheshk172 opened this issue Nov 4, 2019 · 0 comments
Open

Are there any tests written for these examples ? #114

maheshk172 opened this issue Nov 4, 2019 · 0 comments

Comments

@maheshk172
Copy link

I am looking for the sample tests to test the Mutations. I tried the sample provided on the react-relay website, but the MockEnvironment is not working in my case. I am not able find out what is the exact issue.

https://relay.dev/docs/en/testing-relay-components#relaymockenvironment-api-overview

Errors I am facing:

TypeError: Cannot read property 'createOperationDescriptor' of undefined

at commitRelayModernMutation (node_modules/react-relay/node_modules/relay-runtime/lib/commitRelayModernMutation.js:33:57)
at enableHealthCheck (src/common/mutations/EnableHealthCheck.tsx:52:5)
at Object. (src/common/mutations/EnableHealthCheck.test.tsx:27:9)

Extract from commitRelayModernMutations: commitRelayModernMutation()
var _environment$unstable = environment.unstable_internal,
createOperationDescriptor = _environment$unstable.createOperationDescriptor,
getRequest = _environment$unstable.getRequest;
var mutation = getRequest(config.mutation);

Line No 1 => environment.unstable_internal is undefined in this case.

If I run same mutation with react-relay environment, this issue does not appear. This is only coming at the time of testing.

here is my code for Testing Mutation:

const {
createMockEnvironment,
MockPayloadGenerator,
} = require('relay-test-utils');

let environment: createMockEnvironment();
enableHealthCheck(environment, healthCheckInput, onCompleted, onError);
const operation = environment.mock.getMostRecentOperation();

Error is thrown when I call my mutation, which calls commitMutation.

Version
"relay-test-utils": "^7.0.0",
"react-relay": "4.0.0",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant