Wierd issue when running with jest
See original GitHub issueI 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.
PROJECT_FOLDER/node_modules/jest-runtime/build/index.js:439
const wrapper = this._environment.runScript(script)[
^
TypeError: Cannot read property 'Object.<anonymous>' of null
at Runtime._execModule (PROJECT_FOLDER/node_modules/jest-runtime/build/index.js:439:56)
at Runtime.requireModule (PROJECT_FOLDER/node_modules/jest-runtime/build/index.js:296:14)
at Runtime.requireModuleOrMock (PROJECT_FOLDER/node_modules/jest-runtime/build/index.js:365:19)
at Object.getCodec (PROJECT_FOLDER/node_modules/iconv-lite/lib/index.js:61:27)
at Object.getDecoder (PROJECT_FOLDER/node_modules/iconv-lite/lib/index.js:118:23)
at Object.<anonymous>.exports.decode (PROJECT_FOLDER/node_modules/mysql2/lib/parsers/string.js:19:23)
at Packet.Object.<anonymous>.Packet.readNullTerminatedString (PROJECT_FOLDER/node_modules/mysql2/lib/packets/packet.js:371:23)
at Function.Object.<anonymous>.Handshake.fromPacket (PROJECT_FOLDER/node_modules/mysql2/lib/packets/handshake.js:19:31)
at ClientHandshake.Object.<anonymous>.ClientHandshake.handshakeInit (PROJECT_FOLDER/node_modules/mysql2/lib/commands/client_handshake.js:83:38)
at ClientHandshake.Object.<anonymous>.Command.execute (PROJECT_FOLDER/node_modules/mysql2/lib/commands/command.js:39:20)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:11
- Comments:11 (7 by maintainers)
Top Results From Across the Web
Very poor performance on basic tests · Issue #7963 - GitHub
It's weird that Jest reports that a test runs in 10ms but the reported time is 5seconds. Even on my work laptop, running...
Read more >Randomly failing tests jest and supertest Node.js
Tests could pass 10 times in a row and then suddenly that weird 'jest' timer shows up and 3 cases fail. I'm using...
Read more >Jest: Does It Test Funny to You? | Ackee blog
The issue however is that you know about the benefits from the start (easy to write) and feel the pain much later on...
Read more >Jest Testing like a Pro - Tips and tricks
When you run Jest, tests are run by file, within that file you can have groups of related tests, which you put under...
Read more >Fixing Jest Memory Usage on CircleCI | hey it's violet
We realized that the issue might lie with how Jest spawns child processes. Although test output appears linear, the tests by default run...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I found a temporary workaround for now, add this to your
setupTestFrameworkScriptFile
:Might look a bit different depending on your setup 😉
In typescript, just do:
In my case, foo was cp1252