Skip to content

Commit

Permalink
Remove apollo-server-testing (#5239)
Browse files Browse the repository at this point in the history
This was deprecated on main in #5238.
  • Loading branch information
glasser committed May 25, 2021
1 parent f6d54dc commit 1bf1452
Show file tree
Hide file tree
Showing 14 changed files with 3 additions and 289 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -35,6 +35,7 @@ The version headers in this history reflect the versions of Apollo Server itself
- We no longer re-export the entirety of `graphql-tools` (including `makeExecutableSchema`) from all Apollo Server packages. If you'd like to continue using them, install [`graphql-tools`](https://www.graphql-tools.com/) or one of its sub-packages yourself.
- The `Upload` scalar is no longer exported. (See above as to why.)
- Support for serving an HTML UI has been generalized. While servers in dev mode still default to serving GraphQL Playground (note: this may change before v3.0.0), plugins can define a new `renderFrontend` hook which returns an HTML page that is served to browsers. The `playground` option to `new ApolloServer` has been removed; customizing Playground or making it run in production mode can be done by installing the new `ApolloServerPluginFrontendGraphQLPlayground` plugin yourself. To disable Playground, either install the new `ApolloServerPluginFrontendDisabled` plugin or install any other plugin that implements `renderFrontend`. Packages no longer export `defaultPlaygroundOptions`, `PlaygroundConfig`, and `PlaygroundRenderPageOptions`. By default, no GraphQL Playground settings are overridden, including the endpoint, which now just defaults to `window.location.href` (with most query parameters removed); this means you typically don't have to manually configure the endpoint.
- Stopped publishing the deprecated `apollo-server-testing` package. This package is just a wrapper around `server.executeOperation` which you can use directly.

## vNEXT

Expand Down
23 changes: 1 addition & 22 deletions docs/source/testing/testing.md
Expand Up @@ -60,30 +60,9 @@ In addition to `query`, the first argument to `executeOperation` can take `opera
Note that errors in parsing, validating, and executing your operation are returned in the `errors` field of the result (just like in a GraphQL response) rather than thrown.
## `createTestClient` and `apollo-server-testing`
There is also a package called `apollo-server-testing` which exports a function `createTestClient` which wraps `executeOperation`. This API does not support the second context-function-argument argument, and doesn't provide any real advantages over calling `executeOperation` directly. It is deprecated and will no longer be published with Apollo Server 3.
We recommend that you replace this code:
```js
const { createTestClient } = require('apollo-server-testing');

const { query, mutate } = createTestClient(server);

await query({ query: QUERY });
await mutate({ mutation: MUTATION });
```
with
```js
await server.executeOperation({ query: QUERY });
await server.executeOperation({ query: MUTATION });
```
## End-to-end testing
Instead of bypassing the HTTP layer, you may just want to fully run your server and test it with a real HTTP client.
Apollo Server doesn't have any built-in support for this. You can combine any HTTP or GraphQL client such as [`supertest`](https://www.npmjs.com/package/supertest) or [Apollo Client's HTTP Link](https://www.apollographql.com/docs/react/api/link/apollo-link-http/) to run operations against your server. There are also community packages available such as [`apollo-server-integration-testing`](https://www.npmjs.com/package/apollo-server-integration-testing) which provides an API similar to the deprecated `apollo-server-testing` package which uses mocked Express request and response objects.
Apollo Server doesn't have any built-in support for this. You can combine any HTTP or GraphQL client such as [`supertest`](https://www.npmjs.com/package/supertest) or [Apollo Client's HTTP Link](https://www.apollographql.com/docs/react/api/link/apollo-link-http/) to run operations against your server. There are also community packages available such as [`apollo-server-integration-testing`](https://www.npmjs.com/package/apollo-server-integration-testing) which uses mocked Express request and response objects.
28 changes: 0 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -9,7 +9,7 @@
"compile:clean": "tsc --build tsconfig.build.json --clean",
"watch": "tsc --build tsconfig.build.json --watch",
"release:version-bump": "lerna version",
"release:version-bump:server": "npm run release:version-bump -- --force-publish=apollo-server,apollo-server-core,apollo-server-azure-functions,apollo-server-cloud-functions,apollo-server-cloudflare,apollo-server-express,apollo-server-fastify,apollo-server-hapi,apollo-server-koa,apollo-server-lambda,apollo-server-micro,apollo-server-integration-testsuite,apollo-server-testing",
"release:version-bump:server": "npm run release:version-bump -- --force-publish=apollo-server,apollo-server-core,apollo-server-azure-functions,apollo-server-cloud-functions,apollo-server-cloudflare,apollo-server-express,apollo-server-fastify,apollo-server-hapi,apollo-server-koa,apollo-server-lambda,apollo-server-micro,apollo-server-integration-testsuite",
"release:start-ci-publish": "node -p '`Publish (dist-tag:${process.env.APOLLO_DIST_TAG || \"latest\"})`' | git tag -F - \"publish/$(date -u '+%Y%m%d%H%M%S')\" && git push origin \"$(git describe --match='publish/*' --tags --exact-match HEAD)\"",
"postinstall": "lerna run prepare && npm run compile",
"pretest": "npm run compile && tsc --build tsconfig.test.json",
Expand Down Expand Up @@ -50,7 +50,6 @@
"apollo-server-plugin-base": "file:packages/apollo-server-plugin-base",
"apollo-server-plugin-operation-registry": "file:packages/apollo-server-plugin-operation-registry",
"apollo-server-plugin-response-cache": "file:packages/apollo-server-plugin-response-cache",
"apollo-server-testing": "file:packages/apollo-server-testing",
"apollo-server-types": "file:packages/apollo-server-types"
},
"devDependencies": {
Expand Down
6 changes: 0 additions & 6 deletions packages/apollo-server-testing/CHANGELOG.md

This file was deleted.

23 changes: 0 additions & 23 deletions packages/apollo-server-testing/README.md

This file was deleted.

3 changes: 0 additions & 3 deletions packages/apollo-server-testing/jest.config.js

This file was deleted.

36 changes: 0 additions & 36 deletions packages/apollo-server-testing/package.json

This file was deleted.

This file was deleted.

5 changes: 0 additions & 5 deletions packages/apollo-server-testing/src/__tests__/tsconfig.json

This file was deleted.

50 changes: 0 additions & 50 deletions packages/apollo-server-testing/src/createTestClient.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/apollo-server-testing/src/index.ts

This file was deleted.

13 changes: 0 additions & 13 deletions packages/apollo-server-testing/tsconfig.json

This file was deleted.

1 change: 0 additions & 1 deletion tsconfig.build.json
Expand Up @@ -25,6 +25,5 @@
{ "path": "./packages/apollo-server-plugin-base" },
{ "path": "./packages/apollo-server-plugin-operation-registry" },
{ "path": "./packages/apollo-server-plugin-response-cache" },
{ "path": "./packages/apollo-server-testing" },
]
}

0 comments on commit 1bf1452

Please sign in to comment.