question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:open
  • Created 4 years ago
  • Reactions:7
  • Comments:6

github_iconTop GitHub Comments

6reactions
aMonikercommented, Mar 8, 2021

I’m also seeing this issue from the debug package. Do you know of any fix or workaround?

4reactions
MuriloEduardocommented, Jun 28, 2021

I’m having the same error when using automock true. Is this still an unresolved issue?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found