Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kvmw opened this issue Dec 2, 2024 · 4 comments
Closed

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

kvmw opened this issue Dec 2, 2024 · 4 comments

Comments

@kvmw
Copy link

kvmw commented Dec 2, 2024

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
Copy link
Collaborator

mcous commented Dec 2, 2024

@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
Copy link
Author

kvmw commented Dec 2, 2024

@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
Copy link
Collaborator

mcous commented Dec 2, 2024

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
Copy link
Author

kvmw commented Dec 2, 2024

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

@mcous mcous closed this as completed Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants