javascript - Typeorm throws an error due to Jest mocking
问题描述
I am trying to mock typeorm
module using jest.
I am getting following error.
TypeError: __1.getMetadataArgsStorage is not a function
at src/decorator/columns/Column.ts:149:13 at DecorateProperty (node_modules/reflect-metadata/Reflect.js:553:33) at Object.decorate (node_modules/reflect-metadata/Reflect.js:123:24) at Object.<anonymous>.__decorate (src/FakeEntity.ts:4:92)
Codesandbox reproduction.
To run the test just use codesanbox terminal and fire npm run test
command.
I cant make it done, it seems like mocking does not work properly in this setup.It seems valid what jest.requireActual("typeorm")
returns though.I am tinkering with this for quite a while.
Any ideas?
解决方案
推荐阅读
- react-native - React Native:更新数据后未重新渲染组件
- shell - 脚本:检查目录的所有文件是否包含特定字符串,然后在 linux bash 脚本中发送带有该文件名称的邮件
- spring-boot - mvn test 命令未在 Spring Boot 项目中运行测试
- python - 如何在 Django 框架中处理遗留数据库
- php - PHP:使用自定义端口时出现 SoapClient 错误
- flask - 找不到 Flask 应用程序。您没有提供“FLASK_APP”环境变量
- asp.net - @Html.Raw 没有输出任何东西
- vim - 如何从剪贴板复制并粘贴到vim
- ios - 更新 iOS14 后 Flex 网络记录器无法正常工作
- r - 使用 dorng 包的可重复随机数