TypeError: Cannot read property 'prototype' of undefined
See original GitHub issue🐛 Bug Report
I was trying to mock redis module using jest.mock('redis')
. The test failed with following error
TypeError: Cannot read property 'prototype' of undefined
at Object.<anonymous> (node_modules/redis/lib/individualCommands.js:26:13)
at Object.<anonymous> (node_modules/redis/index.js:1102:1)
To Reproduce
Steps to reproduce the behavior:
- install redis
npm i redis@2.8.0
- create a test file
mocking-redis.test.js
with following content
jest.mock('redis');
const redis = require('redis');
describe('Tests', () => {
test('test1', () => {
expect(true).toEqual(true);
});
});
Expected behavior
redis should be mocked and test should pass successfully
Link to repl or repo (highly encouraged)
https://github.com/Amit-Modi/jest-mocking-experiments
envinfo
npx: installed 1 in 1.136s
System:
OS: macOS Mojave 10.14.5
CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Binaries:
Node: 10.16.0 - /usr/local/bin/node
npm: 6.9.0 - /usr/local/bin/npm
npmPackages:
jest: ^24.9.0 => 24.9.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:18
- Comments:8
Top Results From Across the Web
How to fix Uncaught TypeError: Cannot read property ' ...
I fixed this bug. The problem was that I created Collection and then the Model. Collections use user model, as working unit, ...
Read more >TypeError: Cannot read property 'prototype' of undefined · ...
I've come across a TypeError of which I can't seem to find the cause though. Does anyone have an idea where I should...
Read more >exception cannot read property 'prototype' of undefined
So the audit relationship is missing? The relationship is generated automatically when you check the Audited box on any object field. An Audit_< ......
Read more >Cannot read property 'prototype' of undefined
Hi, how do I resolve konyuiBaseClasses.js:4 Uncaught TypeError: Cannot read property 'prototype' of undefined. The problem is I can't load ...
Read more >Uncaught TypeError: Cannot read property 'prototype' of ...
I get an Uncaught TypeError when displaying a page. It says: This issue happens when a subtheme has not been updated to extend...
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 FreeTop 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
Top GitHub Comments
Still happening with Jest 26.4.2
Current workaround I found is to monkey-patch redis.