@testing-library/dom version: "@testing-library/jest-dom": "4.2.4""jest": "24.9.0""jest-environment-jsdom-fourteen": "1.0.1",My Jest Config (fresh from CRA after ejecting):
"jest": {
"roots": [
"<rootDir>/src"
],
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*.d.ts"
],
"setupFiles": [
"react-app-polyfill/jsdom"
],
"setupFilesAfterEnv": [
"<rootDir>/src/setupTests.ts"
],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
"<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}"
],
"testEnvironment": "jest-environment-jsdom-fourteen",
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
"^.+\\.module\\.(css|sass|scss)$"
],
"modulePaths": [],
"moduleNameMapper": {
"^react-native$": "react-native-web",
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
},
"moduleFileExtensions": [
"web.js",
"js",
"web.ts",
"ts",
"web.tsx",
"tsx",
"json",
"web.jsx",
"jsx",
"node"
],
"watchPlugins": [
"jest-watch-typeahead/filename",
"jest-watch-typeahead/testname"
]
},
I was creating simple tests and using the render API - but as I try to navigate the ReturnedResult, the type it returns is any
I thought there was something wrong with my configuration - I made a CRA app with --template=typescript flag and it also returns any. But when I try it in a non-typescript app, it returns its actual type

GitHub repo: https://github.com/sshanzel/dom-testing-library-render-api-issue
Fresh from CRA - using TypeScript template and ejected.
I am quite new with testing frameworks, and I was trying to wander through the library's available APIs, the render API is returning type any though after navigating the actual API from node_modules - it should have been returning the type ReturnedResult which it does not. But I tried it on non-typescript projects - it displays its actual type.
I am not really sure if this has to do with my VS Code but I tried it in a different project (as mentioned above) and it is working as intended.
Can confirm with a minimal repro.
Thanks for the confirmation - sorry though I thought I was at dom-testing-library repo already. Should we be recreating the issue? I can't seem to see the reference transferring of the item.
Should we be recreating the issue? I can't seem to see the reference transferring of the item.
I already transferred the issue.
Thank you! And for keeping this wonderful library as well!
Hi, I'm looking for the first place when I can contribute that's why I investigated that briefly.
FWIU reason for this bug is that CRA is currently using "@testing-library/react": "^9.3.2" which still has a depedeny on "@types/testing-library__dom": "*" which was already removed due to moving types from @types repo to testing-library/dom-testing-library directlly (which has been preformed in 7.5.0. That is why testing-library/react cannot import queries type.
Solutions which should works for that I think are:
Not sure what is easier and more compatible with the current testing-library development direction, so just left comment here and I hope it will be helpful.
FWIU reason for this bug is that CRA is currently using
As showed in https://github.com/testing-library/react-testing-library/issues/801#issuecomment-708943858 the bug is independent of CRA and happens with latest versions. We almost never backport fixes and I don't think we want to spend time on a type-only issues. So let's fix it for the latest version first.
For anyone working on I'd recommend to start with
import {render} from '@testing-library/react'
import * as React from 'react';
function App() {
return null;
}
const {getByText} = render(<App />)
and enable type-checking for libraries i.e. skiLibCheck: false. The any is likely caused by some type-error in the libraries.
Thx for feedback. I tried to reproduce that in on my local new project with minimal setup (as described above), and everything works as expected.
Awesome. Thanks everyone :)
Most helpful comment
Can confirm with a minimal repro.