Next.js: Document how Next and ts-jest coexist

Created on 22 Apr 2020  路  9Comments  路  Source: vercel/next.js

Feature 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

good first issue

Most helpful comment

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.

All 9 comments

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

Was this page helpful?
0 / 5 - 0 ratings