automock is crashing
See original GitHub issue🐛 Bug Report
When setting in jest.config.js property automock: true the tests run is crashing with error
>npx jest
FAIL ./index.test.js
× (30ms)
●
TypeError: Cannot destructure property 'formatters' of 'module.exports' as it is undefined.
> 1 | require('dotenv-parse-variables')
| ^
2 |
at Object.<anonymous> (node_modules/debug/src/node.js:238:8)
at Object.<anonymous> (index.js:1:1)
at Object.<anonymous> (index.test.js:4:3)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 2.893s, estimated 4s
Ran all test suites.
To Reproduce
Consider two files:
index.js
require('dotenv-parse-variables')
index.test.js
jest.unmock('./index')
test('', () => {
require('./index')
})
Steps to reproduce the behavior:
run npx jest
Expected behavior
Jest should not crash
Link to repl or repo (highly encouraged)
https://github.com/Alexsey/jest-automock-crash
envinfo
>npx envinfo --preset jest
npx: installed 1 in 2.334s
System:
OS: Windows 10 10.0.18362
CPU: (4) x64 Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz
Binaries:
Node: 13.7.0 - C:\Program Files\nodejs\node.EXE
npm: 6.13.6 - C:\Program Files\nodejs\npm.CMD
npmPackages:
jest: ^25.1.0 => 25.1.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:6
Top Results From Across the Web
React Jest to match snapshot, crash when testing component ...
js') and i get this error: jest.unmock('ChildComponet.js') was called but automocking is disabled. Remove the unnecessary call to jest.unmock or ...
Read more >digitalmars.D.bugs - [Issue 15832] New: Crashing program when a ...
D.bugs - [Issue 15832] New: Crashing program when a helper template function ... T[] _returns; } auto mock(T)(T f) { return Mock!
Read more >Unit test is crashing - CodeProject
I have been looking at the Google Test documentation, and I think your test code is not correct. The test needs to call...
Read more >Mock car crash emphasizes consequences of unsafe driving ...
Aidan Crowley was shaking as he prepared to stumble from a ruined car onto the Bloomington High School South lawn.
Read more >Solved - Xbox 360 Minecraft RGH is crashing my console
Make sure that you're on the latest TU and that you have "fakelive" and "autofake" disabled. This could fix it. Also did you...
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’m also seeing this issue from the
debugpackage. Do you know of any fix or workaround?I’m having the same error when using automock true. Is this still an unresolved issue?