testing-library / testing-library/react-testing-library

ReactElement not assignable

Open
#1,266 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs more information
Dominant language
JavaScript
Stars
19.7k
Forks
1.2k
Avg merge
3d 16h
Merged PRs (30d)
1

Description

Hello,

I am using Next.js, and I have a problem when trying to test a component with react.createNode or react.createElement. The test cannot understand my component and displays errors. However, on all other components that do not use these features, the tests work fine. My environment:

"next": "14.0.1",
"typescript": "5.2.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"@testing-library/jest-dom": "5.16.5"
"@testing-library/react": "14.1.2",
"@types/react": "18.2.14",
"@types/react-dom": "18.2.6",
"jest-environment-jsdom": "29.3.1",
"ts-jest": "29.1.0",

What I did:

Capture d’écran 2024-01-29 à 09 58 46 (2)

Capture d’écran 2024-01-29 à 09 57 30

Problem description:

Argument of type 'boolean' is not assignable to parameter of type 'ReactElement<any, string | JSXElementConstructor>'.ts(2345)
Parsing error: '>' expected.eslint
'ListPageActionBar' refers to a value, but is being used as a type here. Did you mean 'typeof ListPageActionBar'?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No repository file, test, or minimal reproduction is named; start by reproducing the reported Next.js and TypeScript test case from the screenshots and dependency versions. Determine whether the failure is caused by ReactElement typing, JSX parsing, or test setup, then document a reproducible case and confirm the expected component test behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, next.js, react, typescript
Domain
frontend, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.