-
Notifications
You must be signed in to change notification settings - Fork 119
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
Running Jest doesn't find 'vanilla-jsoneditor' module #334
Comments
As described on josdejong#334 This attempts to make vanilla-jsoneditor module available, specially when working in monorepos.
Thanks for reporting and working on a fix in #335. How can we reproduce this issue exactly? Do you have any pointers of other projects having similar issues with Jest? I would like to better understand what's going on. |
Hi @josdejong, it’s a monorepo project having several modules. I’ve added several libs recently, however this is the only one lib having the issue. It is like if the module wasn’t being detected or something at least at testing time. |
Indeed, and the question is why. How can I reproduce this issue? |
I tried to reproduce it on a separated project (standalone without monorepo) but worked fine. So, I'll to set up a tiny monorepo project and try to reproduce the error on it. |
Thanks Rob! |
I'd sent you an invitation to my repo which you can use it to reproduce the error. |
Thanks for setting up the demo, I can reproduce the issue in your setup. It's quite a complex setup though 😅 . I've done a bit of digging. The root cause seems to be that Jest does not have full ESM support (it is still marked experimental).
I haven't found a solution yet except for the I think there are three options to solve this issue:
|
Hi @josdejong, thanks for following this up :) Can you tell me more about option 2, please?
|
If However, this does not have my preference. in general I would love the JS ecosystem to move away from CommonJS and adopt ESM, not the other way around. The current hybrid situation is a big pain. That's why so far I haven't provided a CommonJS version. See: #196 |
Got it. I'll try these configs you mentioned:
And let it know if any of them works. Otherwise, I might go back to jsoneditor 😞. |
As a workaround, you could also create a script that copies |
Pretty odd, yeh. But, might help for a while. Thanks. |
Sadly, none of them worked :( |
Compared against @tinyhttp/app which it only has this:
instead of something like this:
By doing this, it seems to work. What do you think about it? |
Ahh, that is a good idea! We have to make sure that TypeScript can still find the types (should be the case because of the |
Awesome! I tested it on my setup and it worked. Feel free to use it for your tests. |
😎 I'll do some testing next week, this looks promising. |
This issue should be fixed now in |
Sure, I'll try it today and let you know ;) |
Yei! It worked :) |
😎 Awesome! |
Hi @josdejong -
I'm moving from the old jsoneditor to vanilla-jsoneditor. It was pretty easy, and the component works on runtime as a charm.
However, there's some weird issue when running test cases with jest.
My implementation is basically the same as JSONEditorReact.tsx. Then, when I run tests, this error is thrown:
I've installed
vanilla-jsoneditor": "^0.18.11
and included as part of my dependencies.Accordingly, to what I've read, this can be related to jest-resolver not being able to resolve the types / mapping.
Am I missing something?
Thanks in advance.
The text was updated successfully, but these errors were encountered: