testing-library/svelte-testing-library

TypeError: list.map is not a function (On Mac M1 only)

Closed this issue · 4 comments

kvmw commented

Using the docs to setup testing with svelte 5 (sveltekit) and vitest, I am facing the following error.

 FAIL  src/lib/greeter.svelte.test.js > no initial greeting
TypeError: list.map is not a function
 ❯ HTMLBodyElementImpl.querySelectorAll node_modules/jsdom/lib/jsdom/living/nodes/ParentNode-impl.js:80:66
 ❯ HTMLBodyElement.querySelectorAll node_modules/jsdom/lib/jsdom/living/generated/Element.js:1119:58
 ❯ queryAllByText node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:1469:49
    1467| };
    1468| const getMultipleError$5 = (c, text) => "Found multiple elements with the text: " + text;
    1469| const getMissingError$5 = function (c, text, options) {
       |                                                 ^
    1470|   if (options === void 0) {
    1471|     options = {};
 ❯ node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:1209:17
 ❯ node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:1190:17
 ❯ node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:1233:19
 ❯ src/lib/greeter.svelte.test.js:9:10

This is happening only on a MacOS M1 machine. The set setup is working fine on my linux machine.
I suspect this might be M1 issue. I don't have access to another Mac machine with Intel cpu to verify it.

mcous commented

@kvmw do you have a minimal reproduction repository (or stackblitz or whatever other online environment) available? A difference between ARM64 macOS and another OS is quite odd, given the libraries in play

kvmw commented

@kvmw do you have a minimal reproduction repository (or stackblitz or whatever other online environment) available? A difference between ARM64 macOS and another OS is quite odd, given the libraries in play

@mcous I've created this sample repo to reproduce the issue: https://github.com/kvmw/test

As I said earlier, this is only happening on my mac machine.

OS: macOS 15.1 24B83 arm64
CPU: Apple M1 Pro
Node.js v20.18.0
mcous commented

This appears to be a bug in the nwsapi dependency of jsdom. There was a buggy version released a few days ago. It looks like a fix was released - on my M2 mac I was able to fix the issue by updating nwsapi in the lockfile:

npm update nwsapi

This is the second nwsapi bug I've seen reported here in recent months. If it works for your suite, it may be worthwhile to switch to happy-dom

kvmw commented

Thanks @mcous,
That was it! updating nwsapi v2.2.14 to v2.2.16 fixed the issue.