-
Notifications
You must be signed in to change notification settings - Fork 450
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
Next.js tsconfig.json conflicts / tsconfig
incorrectly camel-cased on docs website
#2805
Comments
The official site is https://kulshekhar.github.io/ts-jest/ No clue why google suggested the other one :( |
I’m not sure the issue you are reporting about, is it about the value of |
I started it because 1) I wanted to point out the incorrect documentation (who does own that site?), and 2) also because I didn't think a good resource existed that talked about the issue between next.js/ts-jest. Re: 2), it turns out people have talked about this issue, I just hadn't googled the right things Re: 1) - Is there any way to fix that documentation, though? |
that documentation is not valid one because it's under a different domain :) the main documentation is under |
In case anyone reached here @ScottyMJacobson's answer works absolutely, however, the latest jest (as of now, it is 29.5.0) will report a warning for the config:
To get rid of the warning, we can change /** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
transform: {
// This is necessary because next.js forces { "jsx": "preserve" }, but
// ts-jest appears to require { "jsx": "react" }
'^.+\\.[jt]sx?$': [
'ts-jest',
{
tsconfig: {
jsx: 'react',
},
},
],
},
} You can also set I personally use |
Hi all, thanks for providing this tool.
I've been trying to get
ts-jest
set up to do some TDD within a TypeScript next.js project.It turns out, next.js will force the
jsx
field topreserve
in yourtsconfig.json
file every time you run it (relevant discussion here, which causes problems forts-jest
(ts-jest
seems to require something like"jsx": "react"
, or you get aSyntaxError: Unexpected token '<'
)A workaround seems to be to leave
"jsx": "preserve"
intsconfig.json
, but manually override the settings injest.config.js
.Googling "different tsconfig.js ts-jest" led me to this documentation site, which is exactly what I needed, except for the fact that I couldn't get it working because
tsConfig
is camelCased across the published docs. (When I went to go fix/PR it in the codebase, however, there was no such camelCasing.)After using the typescript definition for the globals object, I ended up with this jest.config.js (which works)
(I'm writing as verbosely as I am in case it helps anyone else with this issue who google-stumbles across it.)
(And sorry for not following the bug report format)
Thanks!
Scotty
The text was updated successfully, but these errors were encountered: