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.

cannot read property defaults of undefined

See original GitHub issue

with the following…

import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';

const mockAdapter = new MockAdapter(axios);

global.axios = mockAdapter;

I’m getting the cannot read property defaults of undefined, I’ve tried all alternative import methods and still get the same result. Am I missing something?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

15reactions
vova42matterscommented, Apr 21, 2022

In my case I had jest.mock(axios) in test file, removed it and now works as expected

7reactions
rodrigoazvcommented, Apr 4, 2021

I have the same problem, any solution ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

DataTables: Uncaught TypeError: Cannot read property ...
Uncaught TypeError : Cannot read property 'defaults' of undefined (dataTables.bootstrap.js:20). This causes the pagination controls to not ...
Read more >
Uncaught TypeError: Cannot read property ... - DataTables
i am using datatable with this i am facing that error because of that i can not load data table properly because of...
Read more >
Uncaught TypeError: Cannot read property 'defaults ... - GitHub
It look like you created custom javascript, and I would guess you placed it before jquery or jQuery is not loaded correctly.
Read more >
cannot read properties of undefined (reading 'defaults')
Uncaught TypeError : Cannot read property 'defaults' of undefined (dataTables.bootstrap.js:20) This causes the pagination controls to not have styles on them. I ...
Read more >
After cloning i am getting this console error?why?any solution?
... Uncaught TypeError: Cannot read property 'defaults' of undefined ... read our Cookie Policy and visit our Cookie Preference Manager.
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