首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >获取无法找到模块的反应-阿波罗/测试-使用的错误在开玩笑的泰特本机。

问获取无法找到模块的反应-阿波罗/测试-使用的错误在开玩笑的泰特本机。
EN

Stack Overflow用户
提问于 2021-11-23 06:48:02
回答 1查看 857关注 0票数 1

我正在使用jest进行单元测试。但是.I尝试了一些解决方案,但仍然是一样的。请告诉我哪里错了。

失败tests/login-test.js测试套件未能运行

代码语言:javascript
复制
Cannot find module 'react-apollo/test-utils' from 'login-test.js'

  3 | import Login from '../app/components/Login';
  4 | import LoginContainer from '../app/components/container/LoginContainer';
> 5 | import { MockedProvider } from 'react-apollo/test-utils';
    | ^

// package.json

代码语言:javascript
复制
"devDependencies": {
    "@babel/core": "7.9.0",
    "@babel/runtime": "7.9.2",
    "@react-native-community/eslint-config": "^0.0.5",
    "babel-cli": "^6.26.0",
    "babel-jest": "^24.9.0",
    "eslint": "6.8.0",
    "jest": "^24.9.0",
    "jetifier": "^1.6.4",
    "metro-react-native-babel-preset": "^0.56.0",
    "react-test-renderer": "16.8.6"
  },
  "jest": {
    "preset": "react-native",
    "collectCoverage": true,
    "coverageReporters": [
      "json",
      "html"
    ],
    "setupFiles": [
      "./jestSetupFile.js",
      "./node_modules/react-native-gesture-handler/jestSetup.js"
    ],
    "transformIgnorePatterns": [
      "node_modules/(?!react-native|native-base-shoutem-theme|@shoutem/animation|@shoutem/ui|tcomb-form-native|@react-native-community/async-storage|native-base/node_modules/react-native-vector-icons|react-navigation|@codler/react-native-keyboard-aware-scroll-view|react-native-device-info|rn-sliding-up-panel|@react-native-community/masked-view|@react-navigation/bottom-tabs/node_modules/react-native-iphone-x-helper|rn-tooltip|@react-native-community/datetimepicker|node_modules/react-native-tab-view|jsbarcode|@react-native-community/art|@react-native-firebase/analytics|@react-native-firebase|jail-monkey|@dudigital/react-native-zoomable-view/src/ReactNativeZoomableView|@haskkor/react-native-pincode|Platform)"
    ]
  },
  "rnpm": {
    "assets": [
      "./assets/fonts/"
    ]
  }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-11-23 10:06:20

您必须将您的导入更新为:

代码语言:javascript
复制
import { MockedProvider } from '@apollo/client/testing';

来自阿波罗客户端3.0迁移文档

react-apollo v3是一个伞式包,可将下列软件包再导出:

  • @apollo/react-common
  • @apollo/react-hooks
  • @apollo/react-components
  • @apollo/react-hoc
  • @apollo/react-ssr
  • @apollo/react-testing

已不再推荐react-apollo包,现在可以从@apollo/client直接访问上述每个包提供的功能:

  • @apollo/react-hooks ->现在可以直接从@apollo/client获得
  • @apollo/react-components ->现在可从@apollo/client/react/components获得
  • @apollo/react-hoc ->现在可从@apollo/client/react/hoc获得
  • @apollo/react-ssr ->现在可从@apollo/client/react/ssr获得
  • @apollo/react-testing ->现在可从@apollo/client/testing获得
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70076468

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档