Graphql:Typescript + Jest + Relay + Jest似乎无法集成在一起

时间:2019-01-28 12:24:34

标签: reactjs typescript graphql relayjs relaymodern

我正在测试使用Typescript和Relay构建的React应用程序。当我尝试测试继电器供电的组件时,出现以下错误:

 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`.

我正在关注.babelrc文件:


{
  "presets": ["@babel/env", "@babel/react"],
  "plugins": ["relay",
    [
      "transform-relay-hot",
      {
        "schema": "./schema.graphql",
        "watchInterval": 2000,
        "verbose": true
      }
    ]
  ]
}


以及以下Jest配置:

module.exports = {
  roots: ["<rootDir>/src"],
  transform: {
    "^.+\\.tsx?$": "ts-jest",
  },
  testRegex               : "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
  moduleFileExtensions    : ["ts", "tsx", "js", "jsx", "json", "node"],
  transformIgnorePatterns : ["node_modules/(?!(date-fns))"],
  moduleNameMapper: {
      "^Apps(.*)$"      : "<rootDir>/src/apps$1",
      "^Pages(.*)$"     : "<rootDir>/src/pages$1",
      "^Components(.*)$": "<rootDir>/src/components$1",
      "^Logic(.*)$"     : "<rootDir>/src/logic$1",
      "^Theme(.*)$"     : "<rootDir>/src/theme$1",
      "^Config(.*)$"    : "<rootDir>/src/config$1",
      "^Public(.*)$"    : "<rootDir>/src/public$1",
  },
  globals: {
    'ts-jest': {
      tsConfig: "tsconfig.json",
      // diagnostics: false
    }
  },

  setupTestFrameworkScriptFile: "./src/test/test.setup.ts"
};



我在这里错过了什么吗?

0 个答案:

没有答案
相关问题