我正在一个 Expo 项目中工作,遇到一个问题,所有 Jest 测试都因以下原因而失败TypeError:
> Test run started at 5/2/2023, 12:02:30 PM <\n\n FAIL app/utils/story-building-utils/getCurrentWeek.test.ts\n \xe2\x97\x8f Test suite failed to run\n\n TypeError: Cannot redefine property: performance\n\n at Object.<anonymous> (node_modules/react-native/jest/setup.js:407:20)\n\n FAIL app/utils/brainstorm-utils/__tests__/slugify.test.js\n \xe2\x97\x8f Test suite failed to run\n\n TypeError: Cannot redefine property: performance\n\n at Object.<anonymous> (node_modules/react-native/jest/setup.js:407:20)\n\n FAIL app/models/personas/personas.test.ts\n \xe2\x97\x8f Test suite failed to run\n\n TypeError: Cannot redefine property: performance\n\n at Object.<anonymous> (node_modules/react-native/jest/setup.js:407:20)\n\n FAIL app/models/brainstorms/brainstorms.test.ts\n \xe2\x97\x8f Test suite failed to run\n\n TypeError: Cannot redefine property: performance\n\n at Object.<anonymous> (node_modules/react-native/jest/setup.js:407:20)\n\n FAIL app/models/wwxd/wwxd.test.ts\n \xe2\x97\x8f Test suite failed to run\n\n TypeError: Cannot redefine property: performance\n\n at Object.<anonymous> (node_modules/react-native/jest/setup.js:407:20)\n\n FAIL test/i18n.test.ts\n \xe2\x97\x8f Test suite failed to run\n\n TypeError: Cannot redefine property: performance\n\n at Object.<anonymous> (node_modules/react-native/jest/setup.js:407:20)\n\n FAIL app/api/Persona.test.ts\n \xe2\x97\x8f Test suite failed to run\n\n TypeError: Cannot redefine property: performance\n\n at Object.<anonymous> (node_modules/react-native/jest/setup.js:407:20)\n\n FAIL app/services/api/api-problem.test.ts\n \xe2\x97\x8f Test suite failed to run\n\n TypeError: Cannot redefine property: performance\n\n at Object.<anonymous> (node_modules/react-native/jest/setup.js:407:20)\n\n FAIL app/utils/storage/storage.test.ts\n \xe2\x97\x8f Test suite failed to run\n\n TypeError: Cannot redefine property: performance\n\n at Object.<anonymous> (node_modules/react-native/jest/setup.js:407:20)\n\n FAIL app/models/story-building/story-building.test.ts\n \xe2\x97\x8f Test suite failed to run\n\n TypeError: Cannot redefine property: performance\n\n at Object.<anonymous> (node_modules/react-native/jest/setup.js:407:20)\n\n FAIL app/utils/brainstorm-utils/__tests__/shuffleArray.test.js\n \xe2\x97\x8f Test suite failed to run\n\n TypeError: Cannot redefine property: performance\n\n at Object.<anonymous> (node_modules/react-native/jest/setup.js:407:20)\n\n FAIL app/utils/brainstorm-utils/__tests__/parseParams.test.js\n \xe2\x97\x8f Test suite failed to run\n\n TypeError: Cannot redefine property: performance\n\n at Object.<anonymous> (node_modules/react-native/jest/setup.js:407:20)\n\n FAIL app/hooks/useGetBrainstormData/getBrainstormReducer.test.ts\n \xe2\x97\x8f Test suite failed to run\n\n TypeError: Cannot redefine property: performance\n\n at Object.<anonymous> (node_modules/react-native/jest/setup.js:407:20)\n\n FAIL app/models/auth/auth.test.ts\n \xe2\x97\x8f Test suite failed to run\n\n TypeError: Cannot redefine property: performance\n\n at Object.<anonymous> (node_modules/react-native/jest/setup.js:407:20)\n\n FAIL app/utils/brainstorm-utils/__tests__/makeTitle.test.js\n \xe2\x97\x8f Test suite failed to run\n\n TypeError: Cannot redefine property: performance\n\n at Object.<anonymous> (node_modules/react-native/jest/setup.js:407:20)\n\n FAIL app/utils/brainstorm-utils/createUniqueId.test.ts\n \xe2\x97\x8f Test suite failed to run\n\n TypeError: Cannot redefine property: performance\n\n at Object.<anonymous> (node_modules/react-native/jest/setup.js:407:20)\n\n FAIL app/utils/persona-utils/createUniqueId.test.ts\n \xe2\x97\x8f Test suite failed to run\n\n TypeError: Cannot redefine property: performance\n\n at Object.<anonymous> (node_modules/react-native/jest/setup.js:407:20)\n\nTest Suites: 17 failed, 17 total\nTests: 0 total\nSnapshots: 0 total\nTime: 6.061 s\nRan all test suites.\n\n> Test run finished at 5/2/2023, 12:02:37 PM <\nRun Code Online (Sandbox Code Playgroud)\n似乎这个问题是在我从 Expo 44 升级到 48 后开始出现的。我已尝试确保我的软件包版本对于 Expo 48 是正确的,但我仍然遇到此问题。任何帮助表示赞赏!
\n| 归档时间: |
|
| 查看次数: |
3942 次 |
| 最近记录: |