Change __TS_CONFIG__ from a global variable to a jest configuration
See original GitHub issue- Issue It seems silly TS_CONFIG should be a global variable, as the test code does not and should not care about it.
I suggest putting it into a jest configuration key instead e.g.
{
"jest" : {
"ts-jest": {
"__TS_CONFIG__" : {
},
}
This makes more sense, and will later streamline the process of adding more configurations as discussed in #213
This is however a breaking change, and will need deprecation warnings. I also think it would be prudent to support both ways of doing it for a few versions to make sure everyone is caught up. It will be very easy for the end users to migrate.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:32 (17 by maintainers)
Top Results From Across the Web
How use global variable in Jest and pass it through cmd
Use the global object (e.g global.value ) to access globals in the tests console.log(global.value);. Use the --globals parameter to override ...
Read more >Configuring Jest
It is recommended to define the configuration in a dedicated JavaScript, TypeScript or JSON file. The file will be discovered automatically, ...
Read more >Configuration | ts-jest - Huafu
ts-jest configuration is done within Jest configuration object. This latest can be in package.json under the jest property, or in its own jest.config.js...
Read more >Configuring Jest - API Manual
A set of global variables that need to be available in all test environments. For example, the following would create a global __DEV__...
Read more >Documentation - Global .d.ts - TypeScript
Many libraries simply expose one or more global variables for use. For example, if you were using jQuery, the $ variable can be...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Interesting. This is definitely something we should fix, but it doesn’t seem like it’s close enough to this issue to be discussed here. I’d love it if you started a new issue with a repo that reproduces the error.
@morajabi Thanks for picking this up 😃
We can’t skip globals. Any non-standard jest configuration has to go in globals. The structure you’ve used looks fine. Although I’d like to split
__TS_CONFIG
into two distinct keys -tsconfigFile
andtsConfig
to make it clear. (this would require more changes, though) @GeeWee thoughts?There are two places that’ll need change to address this - util.ts and transpile-if-ts.ts
What I’d suggest is
This function should:
If you have any more questions at any stage feel free to post them here!