You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// jest.config.jsmodule.exports={preset: 'jest-preset-ns/presets/react',globals: {// we must specify a custom tsconfig for tests because we need the typescript transform// to transform jsx into js rather than leaving it jsx such as the next build requires. you// can see this setting in tsconfig.jest.json -> "jsx": "react"'ts-jest': {tsconfig: 'tsconfig.test.json',},},setupFilesAfterEnv: ['jest-preset-ns/presets/react/jest-setup.js'],}
Bug Report
Relevant information
It was not possible to use the react preset in a NextJS TypeScript project (https://github.com/natterstefan/nextjs-tailwind-template) directly. The current setup with
ts-loader
did not work. This is most likely because of the currentmodule
andtarget
in thetsconfig.json
in the NextJS project. There is no way to customize this now. Addingtsconfig
inglobals.["ts-jest"]
did not work.In the end, creating a
babel.config.js
(according to https://dev.to/ericdouglas/how-to-configure-jest-on-a-next-js-project-2ic6) and using onlyjest-preset-ns/presets/react/jest-setup.js
helped.Steps to reproduce
yarn test
It also did not work with the
ts-jest
preset, but that's maybe a different problem. Maybe adding the preset directly works?Observed Results
Jest was not able to transpile the files and work with them.
Expected Results
Jest can run the tests
The text was updated successfully, but these errors were encountered: