From 3dd325834bcf67a3fc22b1a2528548c90dc37971 Mon Sep 17 00:00:00 2001 From: Mina Nagy Zaki Date: Thu, 15 Aug 2019 16:57:55 +0200 Subject: [PATCH] jest: fix setup for typeorm to be importable in tests It needs to be transpiled, but also the global window variable was breaking this code: https://github.com/typeorm/typeorm/blob/e4de0403e1f666639c0198e216409f997121c1e8/src/platform/BrowserPlatformTools.template#L20 Also add ConnectionOptions type back to the config object --- jest.config.js | 3 +-- ormconfig.ts | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/jest.config.js b/jest.config.js index a20da47a09..437d07f439 100644 --- a/jest.config.js +++ b/jest.config.js @@ -7,10 +7,9 @@ module.exports = { "enzyme-to-json/serializer" ], transformIgnorePatterns: [ - "node_modules/(?!react-native|native-base|@?react-navigation|react-native-fabric)" + "node_modules/(?!react-native|native-base|@?react-navigation|react-native-fabric|typeorm)" ], globals: { - window: true, "ts-jest": { babelConfig: true } diff --git a/ormconfig.ts b/ormconfig.ts index db250c15e4..ce99502024 100644 --- a/ormconfig.ts +++ b/ormconfig.ts @@ -1,7 +1,8 @@ import { entityList } from './src/lib/storage/entities' import { Initial1565886000404 } from './src/lib/storage/migration/1565886000404-initial' +import { ConnectionOptions } from 'typeorm/browser' -export default { +const typeOrmConfig: ConnectionOptions = { type: 'react-native', database: 'LocalSmartWalletData', location: 'default', @@ -14,3 +15,5 @@ export default { migrationsDir: 'src/lib/storage/migration', }, } + +export default typeOrmConfig