Here is my customized tsconfig settings
{
"compilerOptions": {
"noEmit": true,
"allowJs": true,
"esModuleInterop": true,
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"baseUrl": "./",
"skipLibCheck": false,
"rootDirs": [
"./src",
"../.redwood/types/mirror/web/src",
"../api/src",
"../.redwood/types/mirror/api/src"
],
"paths": {
"src/*": [
"./src/*",
"../.redwood/types/mirror/web/src/*",
"../api/src/*",
"../.redwood/types/mirror/api/src/*"
],
"$api/*": [ "../api/*" ],
"types/*": ["./types/*", "../types/*"],
"@redwoodjs/testing": ["../node_modules/@redwoodjs/testing/web"]
},
"typeRoots": ["../node_modules/@types", "./node_modules/@types"],
"types": ["jest", "@testing-library/jest-dom"],
"jsx": "preserve"
},
"include": [
"src",
"../.redwood/types/includes/all-*",
"../.redwood/types/includes/web-*",
"../types",
"./types"
]
}
Upon running tsc --noEmit --skipLibCheck
, I encounter the following error
error TS2688: Cannot find type definition file for '@testing-library/jest-dom'.
The file is in the program because:
Entry point of type library '@testing-library/jest-dom' specified in compilerOptions
tsconfig.json:29:23
29 "types": ["jest", "@testing-library/jest-dom"],
~~~~~~~~~~~~~~~~~~~~~~~~~~~
File is entry point of type library specified here.
Found 1 error.
Here is how my package.json looks like
{
"name": "web",
"version": "0.0.0",
"private": true,
"browserslist": {
"development": [
"last 1 version"
],
"production": [
"defaults"
]
},
"dependencies": {
"@redwoodjs/auth-dbauth-web": "7.0.0-canary.711",
"@redwoodjs/forms": "7.0.0-canary.711",
"@redwoodjs/router"": "7.0.0-canary.711",
""@redwoodjs/web": "7.0.0-canary.711",
"humanize-string": "2.1.0",
"react": "0.0.0-experimental-e5205658f-20230913",
"react-dom": "0.0.0-experimental-e5205658f-20230913"
},
"devDependencies": {
"@redwoodjs/vite": "7.0.0-canary.711",
"@testing-library/jest-dom": "^6.1.5",
"@types/react": "18.2.37",
"@types/react-dom": "18.2.15",
"autoprefixer": "^10.4.16",
"postcss": "^8.4.32",
"postcss-loader": "^7.3.3",
"prettier-plugin-tailwindcss": "0.4.1",
"tailwindcss": "^3.3.6"
}
}
In order to resolve the issue of finding types for @testing-library/jest-dom
, further investigation and adjustment of dependencies might be required.
Additional information:
The configuration was functional with @testing-library/jest-dom v5, but started failing after upgrading to v6.
If removing it from types
in tsconfig results in type errors regarding missing properties, one workaround could be adding
import '@testing-library/jest-dom'
in a test file. However, understanding why this change is necessary would be beneficial.