score:0

it looks like you've not used the correct file extension here. was your test named doctor.test.ts instead of doctor.test.tsx?

when testing react components you need to ensure you use (j|t)sx extension.

score:1

the error means that jsx syntax isn't recognized by typescript compiler and is parsed as a generic.

since tsconfig.json has "jsx": "react", this means that it wasn't picked up by ts-jest for some reason. the reason is that it was overridden by tsconfig option. a common way to provide a config for tests is to extend another config

tsconfig.test.json

{
  "extends": "./tsconfig",
  "compileroptions": {
    "allowjs": true
  }
}

and specify it for ts-jest:

"tsconfig": "tsconfig.test.json"

also, ts-jest doesn't have extends option, and even if it had, it wouldn't accept babel config. there is babelconfig option for that. since ts-jest transforms typescript and jsx, @babel/preset-react and @babel/preset-typescript may be unneeded in babel config.


Related Query

More Query from same tag