-
-
Notifications
You must be signed in to change notification settings - Fork 633
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
Wierd issue when running with jest #489
Comments
looks like jest module system does not like for some reason dynamic require there: if (!iconv.encodings) {
iconv.encodings = require("../encodings");
} can you try as a work around to monkey patch iconv object? E.i somewhere earlier var iconv = require('iconv-lite')
iconv.encodings = {}; // probably need to put something here, like simple 1:1 decoder or encoder |
@sidorares I'll try that and get back |
@sidorares Thanks! I added the following lines early in my code, and the error went away:
|
looks like this is something worth reporting to jest, I'm closing for now but feel free to post updates here |
@joelchu I'm afraid it's still too little information to debug. Does the error completely go away if mysql2 is not used? |
@joelchu then, why do you comment on an issue related to |
@joelchu this repo has "nothing" to do with |
I found a temporary workaround for now, add this to your
Might look a bit different depending on your setup ;) |
@opatut s/o, is working for me :) |
Thanks @opatut |
In typescript, just do: // Hack to make iconv load the encodings module, otherwise jest crashes. Compare
// https://github.com/sidorares/node-mysql2/issues/489
import * as iconv from 'iconv-lite';
iconv.encodingExists('foo'); In my case, foo was cp1252 |
- Add promise for connections, getConnection, endConnection - Add temporary hack for jest typing issues sidorares/node-mysql2#489
- Add promise for connections, getConnection, endConnection - Add temporary hack for jest typing issues sidorares/node-mysql2#489
As of version 2.x and later for mysql2: |
I know this is very little information, but I've encountered the following when executing some tests with Jest, which touches code that connects to MySQL using
node-mysql2
, but the code makes no queries.Any ideas on what causes this issue? The code is fine, when executed directly.
The text was updated successfully, but these errors were encountered: