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

feat: Show variable matchers in the Variables tab #123

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

PartMan7
Copy link

@PartMan7 PartMan7 commented Sep 3, 2024

PR for #122

Please let me know about any recommended changes to the approach / code!

@lifeiscontent
Copy link
Owner

lifeiscontent commented Sep 4, 2024

@PartMan7 I like the idea of adding support for variableMatcher! One idea would be to have an integration with storybook integration tests so we can use it like apollo suggests in docs for testing. e.g. being able to call variableMatcher as a mock function and actually have storybook integration tests be able to use the variableMatcher mock, what do you think? want to give it a shot? If you don't have time, I can take a look this weekend

the code I'm referring to can be found here:

https://www.apollographql.com/docs/react/development-testing/testing/

import { MockedResponse } from "@apollo/client/testing";

const dogMock: MockedResponse<Data, Variables> = {
  request: {
    query: GET_DOG_QUERY
  },
  variableMatcher: jest.fn().mockReturnValue(true),
  result: {
    data: { dog: { id: 1, name: 'Buck', breed: 'poodle' } },
  },
};

expect(variableMatcher).toHaveBeenCalledWith(expect.objectContaining({
  name: 'Buck'
}));

@PartMan7
Copy link
Author

PartMan7 commented Sep 4, 2024

I'll take a look at this, thanks!

@PartMan7
Copy link
Author

Hi, tried looking into this, but not fully sure how I could get this to work, since functions aren't stringified while passing through The ChannelTM. I'd gotten around this by calling a .toString() on variableMatcher before forwarding; do you have any ideas around this?

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

Successfully merging this pull request may close these issues.

2 participants