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

Testing utilities cleanup #5514

Merged
merged 13 commits into from
Nov 4, 2019
Merged

Testing utilities cleanup #5514

merged 13 commits into from
Nov 4, 2019

Conversation

hwillson
Copy link
Member

This PR reduces the overlap we have between Apollo Client and React mock testing utilities. All mock testing utilities have been pruned and moved into a new location (/utilities/testing), alongside other testing utilities. The utilities we're exporting are bundled into a separate @apollo/client/testing bundle, and kept out of the main AC bundle.

@@ -5,8 +5,8 @@ import { makeReference } from '../utilities/graphql/storeUtils';
import { ApolloLink } from '../link/core/ApolloLink';
import { HttpLink } from '../link/http/HttpLink';
import { InMemoryCache } from '../cache/inmemory/inMemoryCache';
import { stripSymbols } from './utils/stripSymbols';
import { withWarning } from './utils/wrap';
import { stripSymbols } from '../utilities/testing/stripSymbols';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benjamn Just calling this out; I consolidated the testing utilities under a new location of utilities/testing. The previous __tests__/utils location worked, but I didn’t like how our rollup config looked when creating a separate testing bundle from the __tests__ dir. Let me know if the new location works - thanks!

hwillson and others added 13 commits November 4, 2019 11:51
Since we're combining all core + React testing utilities, let's
get them out of the `__tests__` dir. It seemed a bit strange to
create a separate `testing` bundle from a `__tests__` source
location.
We're not using it in AC and it's easy enough to re-create if
people need it.
The mocking utilities aren't mocks themselves, they're intended
to help build mocks.
Make sure the utilities previously exported from the React testing
location are included, and remove the old testing directories.
This method will allow us to avoid passing Promise reject functions as the
first argument to mockSingleLink and the MockLink constructor, to avoid a
breaking change for developers using those testing utilities.
These changes were accomplished using the recently added
src/codemods/mockLinkRejection.ts codemod script, via jscodeshift:

  npm run build
  npx jscodeshift -t dist/codemods/mockLinkRejection.js src/**/*.ts
@hwillson hwillson merged commit ae221cd into release-3.0 Nov 4, 2019
@hwillson hwillson deleted the testing-util-cleanup branch November 4, 2019 17:51
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants