我使用apollo-server-testingpackage编写集成测试遵循这个官方文档。但是当我将ApolloServer类的实例传递给createTestClient方法时,tsc抛出一个类型不兼容的错误。
“ApolloServer”类型的参数不能分配给“ApolloServerBase”类型的参数。属性“requestOptions”的类型不兼容。类型 'Partial>' 不能分配给类型 'Partial>'。属性“documentStore”的类型不兼容。输入'import("/Users/ldu020/workspace/github.com/mrdulin/cnodejs-graphql-api-apollo/node_modules/apollo-server-caching/dist/InMemoryLRUCache").InMemoryLRUCache | undefined' 不可分配到类型 'import("/Users/ldu020/workspace/github.com/mrdulin/cnodejs-graphql-api-apollo/node_modules/apollo-server-testing/node_modules/apollo-server-caching/dist/ InMemoryLRUCache").InMemoryLRUCache ...'。输入 'import("/Users/ldu020/workspace/github.
这是最小的复制代码:
topic.integration.test.ts:
import { constructTestServer } from '../../../__utils';
import { createTestClient } from 'apollo-server-testing';
describe('topic integration test suites', () => {
it('should ', () => {
const { server, cnodeAPI } = constructTestServer();
const { query } = createTestClient(server); // tsc throw an error here
});
});
Run Code Online (Sandbox Code Playgroud)
__util.ts:
import { ApolloServer } from 'apollo-server';
import { …Run Code Online (Sandbox Code Playgroud)