I need to enable some global variables to be reachable for my test so I am setting up a Custom Environment to be used in the testEnvironment
option in my jest.config.json
to achieve that.
For our project we have a TypeScript file that we use for setupFilesAfterEnv
option and that works just fine, however the testEnvironment
seems to support only ES5. Is there any way to use TypeScript in such option?
I successfully created a Custom Jest Environment using ES5 syntax, however since we are injecting global variables I need TypeScript to also declare a global namespace see: https://stackoverflow.com/a/42304473/4655076.
{
///...
setupFilesAfterEnv: ['<rootDir>/test/setup.ts'], // This works with ts
testEnvironment: '<rootDir>/test/customJestEnvironment.ts', // This doesn't work with ts
}