Replies: 8 comments 8 replies
-
Next.js breaks my Jest tests. It overwrites Also this sounds alarming from Next.js: |
Beta Was this translation helpful? Give feedback.
-
This also causes intellisense issues with Typescript. If jsx is set to preserve, then VSCode recommends importing React when it's no longer necessary in React 17. |
Beta Was this translation helpful? Give feedback.
-
It would be better if NextJS would warn/notify of potential issues instead of overriding the Overriding the file could then be exposed as an opt-in config. |
Beta Was this translation helpful? Give feedback.
-
also changing the property |
Beta Was this translation helpful? Give feedback.
-
The "solution" proposed above to make it work with jest does not work for me when I try it with Vitest. import { defineConfig } from "vite";
export default defineConfig({
test: {
environment: "jsdom",
typecheck: {
tsconfig: "./tsconfig.test.json",
}
},
}); Has anyone been able to solve it or has the same problem? |
Beta Was this translation helpful? Give feedback.
-
Future reference: for those who are facing issues with rollup (
|
Beta Was this translation helpful? Give feedback.
-
To anyone who has this problem ( const nextJest = require('next/jest')
const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: './',
})
// Add any custom config to be passed to Jest
/** @type {import('jest').Config} */
const config = {
// Add more setup options before each test is run
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
testEnvironment: 'jest-environment-jsdom',
preset: 'ts-jest',
}
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
module.exports = createJestConfig(config) |
Beta Was this translation helpful? Give feedback.
-
Apparently having react in path, like: "paths": {
"@/*": ["./*"],
"react": ["./node_modules/@types/react"]
} will solve it (no need to import react). Learned from shadcn/ui. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Feature request
Do not force update tsconfig.json
Is your feature request related to a problem? Please describe.
I want use next-js as dev-server for development components. With "jsx": "preserve" tsc builds .jsx files instead .js. For fix this i should use "jsx": "react". But when i start next-js, tsconfig.json updated by them.
Yes, i can create tsconfig.build.json
but in this case i do not see errors if have not
import React from "react"
Beta Was this translation helpful? Give feedback.
All reactions