Document how Next and ts-jest coexist
See original GitHub issueFeature request
Is your feature request related to a problem? Please describe.
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.
Describe the solution you’d like
Write a page in https://nextjs.org/docs/ saying how to get started testing.
Describe alternatives you’ve considered
- The documentation could also go in https://kulshekhar.github.io/ts-jest/user/config/.
- The solution in https://github.com/zeit/next.js/tree/canary/examples/with-jest (1) doesn’t use typescript and (2) according to https://kulshekhar.github.io/ts-jest/user/babel7-or-ts would fail to typecheck the tests.
- An even better alternative would be to improve ts-jest somehow to cope with JSX tags in its source, but that seems more work than just documenting the workaround.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Setting up Jest and Enzyme for Typescript Next.js apps
js + Typescript setup using ts-jest. This is one of these post: explaining how to glue pieces together and humbly describes ...
Read more >How to Setup Next.js + TypeScript + Eslint + Storybook + Jest ...
js project! Next, create a tsconfig.json file with the following command: touch tsconfig.json. Install some TypeScript dependencies:
Read more >Setting up a project with jest in TypeScript. - ITNEXT
A step by step process of creating a project in TypeScript and setting up a test environment with jest using Visual Studio Code....
Read more >How to configure Jest with TypeScript | Swizec Teller
Making Jest and TypeScript work together smoothly is something you do ... For the initial setup we can use ts-jest's install documentation.
Read more >Configuring Jest
The configuration also can be stored in a JSON file as a plain object: ... The babel and v8 coverage providers use /*...
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 Free
Top 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

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.Closing per above and that we allow
module: 'commonjs'onnext@canary!