【发布时间】:2022-06-15 22:52:11
【问题描述】:
我正在尝试让 Jest 使用 TypeORM Expo-Example project
为了让 ts-jest 和 expo-jest 正常工作,我做了很多工作。我遵循了Jest 和Expo Jest 的官方指南。我能够 expo 初始化一个新的空项目(不是 TypeORM 示例)并让 Expo-Jest 按预期工作,但是当我将更改应用到 TypeORM expo 项目时,它遇到了问题。
我认为 expo-jest 是首选。从 TypeORM Expo-Example repo 的干净克隆开始可能会更容易。
我已将 package.json 编辑为一个不应该有依赖问题的版本,如果它是一个更容易的起点。 (可以修改或删除玩笑的东西以支持单独的配置)
{
"name": "expo-example",
"version": "0.1.0",
"private": true,
"devDependencies": {
"@babel/core": "^7.18.0",
"@babel/preset-env": "^7.18.0",
"@types/jest": "^27.5.1",
"@types/node": "^10.1.3",
"@types/react": "~17.0.21",
"@types/react-native": "~0.67.6",
"@types/react-test-renderer": "^16.0.1",
"babel-plugin-transform-typescript-metadata": "^0.3.2",
"jest": "27",
"jest-expo": "^45.0.1",
"react-native-typescript-transformer": "^1.2.9",
"react-test-renderer": "17",
"typescript": "^4.6.4"
},
"scripts": {
"start": "expo start --dev-client",
"eject": "expo eject",
"android": "expo run:android",
"ios": "expo run:ios",
"test": "jest",
"postinstall": "patch-package"
},
"jest": {
"preset": "jest-expo",
"moduleFileExtensions": [
"ts",
"tsx",
"js"
],
"transform": {
"^.+\\.(js)$": "<rootDir>/node_modules/babel-jest",
"\\.(ts|tsx)$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"testPathIgnorePatterns": [
"\\.snap$",
"<rootDir>/node_modules/"
],
"cacheDirectory": ".jest/cache",
"transformIgnorePatterns": [
"node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|react-native-svg)"
]
},
"dependencies": {
"babel-jest": "27",
"expo": "^45.0.0",
"expo-splash-screen": "~0.15.1",
"expo-sqlite": "~10.2.0",
"expo-status-bar": "~1.3.0",
"patch-package": "^6.4.7",
"postinstall-postinstall": "^2.1.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-native": "0.68.1",
"react-native-sqlite-storage": "^4.1.0",
"react-native-web": "0.17.7",
"reflect-metadata": "^0.1.13",
"ts-jest": "27",
"tslib": "^1.9.1",
"typeorm": "^0.3.6"
}
}
【问题讨论】:
-
如果您可以发布您遇到的错误和您尝试过的内容,这将有很大帮助
标签: react-native expo typeorm ts-jest babel-jest