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(mergeMocks): support Promise #1883

Merged
merged 1 commit into from Aug 10, 2020

Conversation

MLKiiwy
Copy link
Contributor

@MLKiiwy MLKiiwy commented Aug 4, 2020

In my opinion it's a bug fix : mergeMocks function signature accept any type, so Promise type should be covered.

  • add Promise support on mergeMocks
  • add test to cover it

Context

In our application, we use the mocks with Promise result.
That gives us the possibility to test the "pending" and "error" state of a query or a mutation more easily. (and also the optimistic UI part can also be covered during pending state)
Actually it's really working fine and it's way easier to use on Frontend side compare to other mock utilities (for example the "mock" request system of apollo is awful)

We discover that if we define a custom mock + use Promise the custom mock override the expected result.
It's because of this test:

  if (isObject(customMock)) {
    return mergeObjects(genericMockFunction(), customMock);
  }

Promise is an object, but you can merge it as an object ...

--

  • Make sure all of the significant new logic is covered by tests
  • Rebase your changes on master so that they can be merged easily
  • Make sure all tests and linter rules pass

@MLKiiwy MLKiiwy force-pushed the fix-merge-mocks-promise-type branch from 522f3e0 to 84cddf6 Compare August 10, 2020 08:01
@MLKiiwy
Copy link
Contributor Author

MLKiiwy commented Aug 10, 2020

@ardatan Hi, I don't understand why one action is failing can someone look at it or retry the action?

@ardatan
Copy link
Owner

ardatan commented Aug 10, 2020

Thank you for PR :) It is not important.

@ardatan ardatan added the feature New addition or enhancement to existing solutions label Aug 10, 2020
@ardatan ardatan changed the title fix(mergeMocks): support Promise feat(mergeMocks): support Promise Aug 10, 2020
@ardatan ardatan merged commit f4bafe0 into ardatan:master Aug 10, 2020
@theguild-bot
Copy link
Collaborator

The latest changes of this PR are available as alpha in npm: 6.0.17-alpha-f4bafe01.0

Quickly update your package.json by running:

npx match-version @graphql-tools 6.0.17-alpha-f4bafe01.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New addition or enhancement to existing solutions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants