From https://github.com/zeit/next.js/issues/3663#issuecomment-385361537 and https://github.com/zeit/next.js/issues/8663, it looks like no single value for the tsconfig's compilerOptions.jsx works for both Next.js (which requires "preserve") and Jest (which requires "react"). Those issues suggest configuring ts-jest to use a separate tsconfig.jest.json, but their guidance hasn't made it into any actual documentation that I can find.
Write a page in https://nextjs.org/docs/ saying how to get started testing.
You should be using the with-jest example, which supports TypeScript files, and be relying on next build to run the type checking (which it does)!
I tried the with-jest example, introduced a type error, and neither npm test nor npm run build failed. A type error did cause npm test to fail when I followed the linked issues' advice.
Even if with-jest did work for typescript, an example isn't a complete substitute for a documentation page that describes how you intend folks to test their projects.
Feel free to send a PR.
does anybody know any workarounds?
@meoyawn
There is already an example with-typescript-eslint-jest.
So, I think this issue should have closed :thinking:
Closing per above and that we allow module: 'commonjs' on next@canary!
@Timer
Thank you for closing this issue :bow:
Do you think if we should put a the with-typescript-eslint-jest example link on with-jest's README ?
I don't think it's necessary, the with-jest example covers TypeScript usage already.
thanks @bobstrange @Timer
Most helpful comment
I tried the
with-jestexample, introduced a type error, and neithernpm testnornpm run buildfailed. A type error did causenpm testto fail when I followed the linked issues' advice.Even if
with-jestdid work for typescript, an example isn't a complete substitute for a documentation page that describes how you intend folks to test their projects.