-
Notifications
You must be signed in to change notification settings - Fork 5
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
Error when running unit tests #83
Comments
As a small note, I would like to add that this error could possibly be caused by the following (found on StackOverflow), the index.js file of the Leaflet module is compiled into th ESM syntax instead of the CommonJS syntax, which seems to be causing all of the trouble, since Jest is not able to process it. This page offers a way to activate support for ESM on the tests, but I have not been able to try it yet and don't know if it would be recommendable or not: jestjs.io/docs/ecmascript-modules. |
In webapp/package.json, put the following line: "test": "react-scripts test --transformIgnorePatterns \"node_modules/(?!ol)/\" --coverage", |
I have seen the error in a repository Use "import { TextEncoder, TextDecoder } from 'util'; |
Try to append the following in the webapp/src/setUpTests.ts, after the last line: import { TextEncoder, TextDecoder } from 'util';
global.TextEncoder = TextEncoder;
(global as any).textDecoder = TextDecoder; |
Fantastic, this does finally solve the problems with Jest, it has all been fixed and updated in develop (commit 8378946) |
I got the same exact error using Maps api, so I think is rather a solid library -related issue as you mentioned before (I actually accessed this issue from there ) I used the solution mentioned here:
since
is not working for some reason ( maybe because i use javascript not ts) thank you ! |
An error when trying to run the unit tests has been found, this error is not allowing the exeuction of the tests because of an issue with one of the Leaflet modules and how Jest is processing it, or at least that is how I have understanded the following trace:
After a quick search on StackOverflow, I was able to find someone with this exact same problem: Link
Unfortunately, I have already tried changing the configuration of our jest.config.ts to what he proposes on the forum, right now it is like this:
I think this is a very important matter and should be taken care as soon as possible, since this prevents us from testing any test that imports any of the Leaflet modules.
Just in case, this is how the test is defined, I do not think this problem is related to the code, but to the configuration, but just to make sure this is how it is coded:
The text was updated successfully, but these errors were encountered: