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

Problems with Jest and get-own-enumerable-property-symbols #77

Closed
erikbrinkman opened this issue Jan 15, 2023 · 0 comments
Closed

Problems with Jest and get-own-enumerable-property-symbols #77

erikbrinkman opened this issue Jan 15, 2023 · 0 comments

Comments

@erikbrinkman
Copy link

The way that get-own-enumerable-property-symbols is imported isn't supported by jest, and instead crashes with:

TypeError: <local name>.default.default is not a function or its return value is not iterable

A few day ago someone seems to asked about this on stack overflow, but gave up and just resorted to JSON.stringify.

It's happening here:

...getOwnEnumPropSymbols.default(input),

essentially because of differences in how modules are handled. Some libraries handle this just fine, but babel + jest seems to add an extra unnecessary .default.

In my reading of it, that .default shouldn't be necessary as the import name from "module" should already be taking the default export. Removing the extra .default causes jest to work fine, but breaks your ava tests.

This makes me think that it's an issue with ava, but since I'm not super familiar, it was hard for me to trace down how ava is executing the imports. It seems like it's due to the very odd format of get-own-enumerable-property-symbols that exports an anonymous const arrow function, instead of a default named function or potentially a named const.

One fix for both jest and ava was to avoid depending get-own-enumerable-property-symbols and just redeclaring the relatively simple function inside stringify-object, but that has its own downsides.

This leaves a few potential solutions:

  1. Do nothing and leave me to forking the patch :'(
  2. Remove the default and figure out why ava seems to be misinterpreting the default export. This I probably can't help with.
  3. Remove get-own-enumerable-property-symbols and inline the function. I have a PR ready, but wanted to see what your thoughts were before submitting it.
  4. Something else that I missed or didn't understand that resolves this in some other way.

Thanks for the nice library!

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

1 participant