globalSetup and globalTeardown doesn't seems to be transpiling correctly (w/ TypeORM)
See original GitHub issueIssue :
I’m trying to test a GraphQL API with a in-memory SQLite database with TypeORM. Currently I have to create a connection in every .test file in the beforeAll (this method also has caveats because I’m limited to use --runInBand). I then tried to globally start the database with my fixtures with globalSetup, but I’m getting a weird error:
import { EntitySubscriberInterface, EventSubscriber, InsertEvent } from "typeorm";
^
SyntaxError: Unexpected token {
Usually that would mean that it’s trying to parse Typescript instead of transpiled Javascript.
I’ve made a sandbox reproduction here.
Try to run yarn test
without modifications and it will work as expected, but by uncommenting the 2 lines in jest.config.js you will get the error above.
I’m not sure if this issue is upstream with Jest or with TypeORM, so feel free to point me where this issue should go if it’s not in the right repo.
Thank you 😃
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:6
Top GitHub Comments
@Drakota In case you’re still looking for a solution, this worked for me: https://github.com/facebook/jest/issues/5164#issuecomment-376006851
I worked around this by using
setupFilesAfterEnv
instead. This still allows me to access my TypeORM connection in all of my tests, and I don’t need to installts-node
as a dependency.jest.config.js
node.d.ts
jest.setup.ts
createConnection.ts