It seems like Code sandbox has an old version of JSDOM (4.0.0) hard coded into the bundle: https://github.com/codesandbox/codesandbox-client/pull/1812/files#diff-3fcdeb2de813a974b29d8610b234c7f2R51
Testing Library users have been having issues like testing-library/user-event#391 which are caused by bugs in JSDOM that have since been fixed in newer versions. This could theoretically affect any project running Jest tests that rely on JSDOM though (including create-react-app's default configuration).
For reference, it seems like Jest is currently using JSDOM 12, and in the future will be using JSDOM 16. It would be nice if we could either automatically detect Jest's version of JSDOM or use the latest dynamically via Unpkg/npm. If that's not possible, just upgrading the hard coded version to 12 or 16 should help a lot. I would have tried to do this myself, but JSDOM doesn't seem to release a single bundle file any more.
If you download this and run the test script locally, it will pass because Jest is using a newer version of JSDOM that fixes the bug with the initial values of selectionStart and selectionEnd. This is also the same behavior if you run similar code in a browser.
| Software | Name/Version |
| ---------------- | ------------ |
| 小odesandbox | latest at the time of issue |
| Browser | N/A |
| Operating System | N/A |
This is a good point! Just opened a PR for it, I think the best long term solution would be to indeed dynamically install JSDOM, but with the current version it would create quite a slowdown. That's why we have some preprocessing tied to it right now. I automated that part now though, so it becomes easier to stay up to date.
Most helpful comment
This is a good point! Just opened a PR for it, I think the best long term solution would be to indeed dynamically install JSDOM, but with the current version it would create quite a slowdown. That's why we have some preprocessing tied to it right now. I automated that part now though, so it becomes easier to stay up to date.