점점을 찾을 수 없는 모듈은'반-아폴로/스 테스트-utils'오류 농담으 teact native

0

질문

나는 단위 테스트를 수행하여 농담. 하지만 아래에 오류가 있습니다.나가려고 일부 솔루션 하지만 여전히 동일합니다. 을 제안하십시오 나는 내가 잘못입니다.

실패 테스트를/login-test.js ●테스트를 실행하지 못

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';
    | ^

//패키지입니다.json

"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/"
    ]
  }
graphql jestjs react-apollo react-native
2021-11-23 06:48:02
1

최고의 응답

1

당신 업데이트로 가져오기:

import { MockedProvider } from '@apollo/client/testing';

에서 아폴로 클라이언트 마이그레이션 3.0doc:

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
2021-11-23 10:06:20

시간 내 주셔서 감사합니다 하지만 여전히 같은 오류가●테스트하는 데 실패했을 찾을 수 없는 모듈'@apollo/클라이언트가/테스'
Abhigyan Gaurav

은 당신이 설치되어 있는지 확인하십시오@apollo/클라이언트? 도 npm install @apollo/clientyarn add @apollo/client 사용하는 경우에는 털실
Fraction

그 작업은 많은 감사
Abhigyan Gaurav

나는 확실하지 않 버전을 아폴로의 클라이언트를 사용하지만 나는 가정의 v3(@apollo/client이후)당신이 당신 말을 사용하여 react-apollo": "3.1.5"하지만 경우에 당신을 사용하여 v2(apollo-client는 오래된 버전)설치해야 npm install [email protected] --save 유지 import { MockedProvider } from 'react-apollo/test-utils';
Fraction

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................