jaredpalmer / tsdx

Zero-config CLI for TypeScript package development
https://tsdx.io
MIT License
11.29k stars 507 forks source link

target.documentOwner.createRange is not a function #1145

Open cherryramatisdev opened 2 years ago

cherryramatisdev commented 2 years ago

Current Behavior

After updating the libraries @testing-library/react @testing-library/user-event to the new version (to follow the update of react 18) I'm experiencing an error while running my unit tests(as shown below):

image

I also tried to install babel-jest, but the error changed to a more abstract error message(as shown below):

image

Disclaimer: I created an example repository that contains two branches (https://github.com/cherryramatisdev/test-poc-user-event)

  • master has a solution with the same packages but without tsdx
  • use-tsdx has a solution with the same packages but with tsdx

Expected behavior

Run the unit tests correctly while using styled-components and user-events to check for user interactions.

Suggested solution(s)

N/A

Additional context

I found this PR related with a workaround comment: https://github.com/jaredpalmer/tsdx/pull/679, but doesn't quite work for me on the real codebase(it throws a lot of errors related to DOM finding) and it's from 2021, I would like to know if we have a more official solution.

Your environment

  System:
    OS: Linux 5.15 Ubuntu 22.04 LTS 22.04 LTS (Jammy Jellyfish)
    CPU: (2) x64 Intel(R) Core(TM) i5-9400 CPU @ 2.90GHz
    Memory: 3.01 GB / 3.80 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.15.1/bin/yarn
    npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm