如何修复中继单元测试抛出错误“不变违规:graphql:运行时意外调用”?

Moh*_*don 5 typescript jestjs relayjs ts-jest

我正在使用react+relay+jest+typescript,但我的测试失败了,因为它们无法理解graphql。抛出的错误是:

Error: Uncaught [Invariant violation: graphql: Unexpected invocation at runtime.
Either the babel transform was not set up, or it failed to identify this call
site. Make sure it is being used verbatim as `graphql`.]
Run Code Online (Sandbox Code Playgroud)

我在 jest.config 中使用 ts-jest。并且它在运行应用程序时按预期工作。在运行测试时它失败了。