在React-Native中运行UIT时,Jest在React-Navigation中给出错误

tv6aics1  于 2023-03-10  发布在  Jest
关注(0)|答案(1)|浏览(140)

尝试在react native中运行UI测试时,从Jest中获取错误。同时更新了package.json文件

"jest": {
"preset": "react-native",
"setupFiles": [
  "<rootDir>/jest/setup.js"
]},"transformIgnorePatterns": [
"node_modules/(?!((jest-)?react-native|react-navigation|@react-navigation/.*))"]

在**/jest/setup.js**中,仅导入jest.mock('@react-navigation/native-stack')

hrirmatl

hrirmatl1#

在package.js中添加以下代码
///修改此代码
“笑话”:{
“预置”:“React-原生”,
“重置模拟”:假的,
“设置文件”:[

"<rootDir>/jest/setup.js",

  "./node_modules/react-native-gesture-handler/jestSetup.js"

],

"transformIgnorePatterns": [

  "/node_modules/(?!(@react-native|react-native)/).*/"

],

"setupFilesAfterEnv": [

  "@testing-library/jest-native/extend-expect"

],
“模块名称Map器”:{

".+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "babel-jest"
}}

那就进行测试

相关问题