首页 > 解决方案 > 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?

标签: javascriptjestjsmockingtypeorm

解决方案


推荐阅读