-
Notifications
You must be signed in to change notification settings - Fork 460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change __TS_CONFIG__ from a global variable to a jest configuration #217
Comments
Sounds like a good idea. Although it might be better to use something other than |
Yeah It should definitely be |
Do you want me to take a crack at this @kulshekhar ? |
@GeeWee sure! The change itself should be straightforward but all the tests that use this would need to be updated as well. And the readme. Also, for the time being, it might be a good idea to let both We can probably show some sort of a warning for the users of the old setup so that by the time the next version of Jest (or the one after that) is out, we can complete the switch. |
I'm thinking since we'll want to maintain both behaviours at the start, I'll duplicate all the tests for the new functionality, but just testing for the new key, and then maintain all the old tests unchanged, except that they'll now check for a warning message, to make sure the users are informed. What is |
I think it might be enough to change the existing tests to use I used |
When you say |
no .. I meant it like breadcrumbs. So {
"globals": {
"ts-jest": {
"__TS_CONFIG__": { }
}
}
} |
Ah, I see.
aka outside of the globals key. |
I think jest will show a warning on the console if it's done that way |
Damnit, you're right. Globals it is then! |
If this is implemented ts-jest should check both |
Yes, that'll probably be the best way. I think |
Completely agree. |
@GeeWee are you working on this? |
Not currently, focusing on Babel atm. Might get around to this, but it won't be for a week+ |
I can't actually contribute any code until next weekend due to legal stuff at work (IBM requires a bunch of legal gymnastics to contribute to open source but next Friday is my last day). I'd be more than happy to look into this if no one else has gotten to it by then. |
I have an issue with the way this is currently implemented. Trying to run |
Interesting. Where is the jest --projects switch documented? It's not here |
It's mentioned in this blog post and also here in the docs: https://facebook.github.io/jest/docs/en/configuration.html#projects-array-string. Interestingly, the I think the the |
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. |
I'm fixing this but should I use this syntax as it is now on README?
or simply skip globals? |
Sorry, What should I do with |
@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
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! |
@kulshekhar Thanks kind man.
What is the difference between them? Is |
Yes, to what they'd stand for. I should point out that, currently, the config is not merged. It is overwritten. If both Edit: The more I think about this, the more I feel we shouldn't allow setting the raw config at all. It would be much simpler (for us and for the users) to just use a different tsconfig file ( |
Why not merge? |
Merging different configurations can lead to hard debug issues. Moreover, if someone wants to do this, tsconfig already has |
I think having two configuration entries is a pretty bad idea, as you'll need to remember what takes precedence, etc. |
Welcome aboard btw @morajabi |
I'm strongly in favor of having only one, optional, tsconfigFile option. |
I can't come up with a case where you'd need to do it inline, so this is fine with me. |
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.
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.
The text was updated successfully, but these errors were encountered: