-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add option to getTestDatabase to pass TypeORM config object (#7)
This feature supports projects that use a TypeScript `ormconfig.ts` file. Currently originate-scripts is not able to read TypeORM configuration from TypeScript modules which is required to get `getTestDatabase` to run migrations for you. If you use a TypeScript configuration module then you can import it in your test, and pass the exported value to `getTestDatabase`. For example: ```ts const { stop } = await getTestDatabase({ // We use a callback to delay evaluating `ormconfig` until after // `process.env.DATABASE_URL` is set by `getTestDatabase`. typeormConfig: async () => (await import('../../ormconfig')).default, }) ``` Note that it is important to delay evaluating `ormconfig.ts` until **after** `getTestDatabase` has set the `process.env.DATABASE_URL` environment variable. The example above demonstrates using the `await` operator to import configuration in a callback. To make that example work your `ormconfig.ts` module should export its configuration object as the default export using `export default config`.
- Loading branch information
Jesse Hallett
authored
Apr 13, 2022
1 parent
3669a79
commit 4629a38
Showing
5 changed files
with
37 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters