solidjs / solid-testing-library

Simple and complete Solid testing utilities that encourage good testing practices.
MIT License
201 stars 19 forks source link

Breaking issue with Node 20 #48

Closed JoeMorgan closed 10 months ago

JoeMorgan commented 1 year ago

When switching to Node 20.6.1, all of my tests fail due to the following error:

TypeError: dispose is not a function
 ❯ cleanupAtContainer node_modules/@solidjs/testing-library/dist/index.js:125:3
    123| function cleanupAtContainer(ref) {
    124|   const { container, dispose } = ref;
    125|   dispose();
       |   ^
    126|   if (container?.parentNode === document.body) {
    127|     document.body.removeChild(container);

This problem does not occur with Node v19.9 or previous.

Dependencies/versions:

  "devDependencies": {
    "@solidjs/testing-library": "^0.8.4",
    "@testing-library/jest-dom": "^5.17.0",
    "@testing-library/user-event": "^14.4.3",
    "@vitest/coverage-v8": "^0.33.0",
    "esbuild": "^0.19.2",
    "eslint": "^8.47.0",
    "eslint-config-prettier": "^9.0.0",
    "eslint-plugin-solid": "^0.12.1",
    "husky": "^8.0.3",
    "jsdom": "^22.1.0",
    "lint-staged": "^14.0.0",
    "postcss": "^8.4.21",
    "prettier": "3.0.2",
    "solid-start-netlify": "^0.2.29",
    "solid-start-node": "^0.2.19",
    "vite": "^4.1.4",
    "vitest": "^0.33.0"
  },
  "dependencies": {
    "@azure/msal-browser": "^2.38.1",
    "@solidjs/meta": "^0.28.2",
    "@solidjs/router": "^0.8.2",
    "diff": "^5.1.0",
    "solid-js": "^1.7.11",
    "solid-start": "^0.3.2",
    "undici": "^5.15.1"
  },
aadito123 commented 1 year ago

Same here

atk commented 1 year ago

This is an issue with vitest, not with testing-library. It loads two versions of solid-js, one through the node loader and one through the vite dev server. This breaks solid-js; our auto-cleanup is just the first part that throws.

JoeMorgan commented 1 year ago

Thanks @atk . Do you happen to know if there is an open ticket in the vitest repo that you're tracking? I am looking but coming up short.

atk commented 1 year ago

I haven't created such a ticket, but I have mentioned it to the devs on discord.

rcannood commented 1 year ago

Encountering the same issue when using Vitest with SolidJS and NodeJS 20. Based on the previous discussion, it isn't yet clear to me what the problem is. Should we create an issue at https://github.com/vitest-dev/vitest/issues ?

joeatwawa commented 10 months ago

Note that this seems to be resolved when using the latest version of vitest (which is 1.2.0 at the time of this writing). I will close this issue.

JoeMorgan commented 10 months ago

Resolved in latest vitest