TypeError: $.extend is not a function
See original GitHub issueHi, i just use toastr for a few days. I have problem when testing my action (react). Here’s the error:
TypeError: $.extend is not a function
at getOptions (node_modules/toastr/toastr.js:452:26)
at Object.error (node_modules/toastr/toastr.js:49:32)
at static/js/actions/action_coa.js:17:14
at <anonymous>
I’m using mocha, chai and nock Here’s my test code:
it('should create a FETCH_ALL_COA action', () => {
nock(`http://${ROOT_URL}`)
.get('api/coa/?format=json')
.reply(200, dummy_coa);
const store = mockStore({ coa: {} });
let expectedAction = [{ type: FETCH_ALL_COA, payload: [{
...dummy_coa
}]}];
return store.dispatch(fetchAllCOA())
.then(() => {
expect(store.getActions()).to.eql(expectedAction);
});
});
beside this error, it also give a warning on my console (testing result ):
(node:2758) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 745): TypeError: $.extend is not a function
my action code:
import axios from 'axios';
import {ROOT_URL, FETCH_ALL_COA, FETCH_COA, DELETE_COA} from './types.js';
import toastr from '../components/my_toastr.js';
export function fetchAllCOA(token){
const url = `${ROOT_URL}api/coa/?format=json`;
const request = axios.get(url, {headers:{Authorization:token}});
return (dispatch => {
return request.then(data => {
dispatch({type: FETCH_ALL_COA, payload: data.data});
}).catch(() => {
toastr.error('Can\'t connect to server!<br />' +
'Please check your internet connection', 'Error!');
});
});
}
Pardon my English, it’s not my native language.
Please help me, wether i made some mistakes or did i miss something. Thank you
Issue Analytics
- State:
- Created 6 years ago
- Comments:7
Top Results From Across the Web
extend is not a function - jquery - Stack Overflow
The problem is (as far as I can see from the source code), that the editor directly accesses the global $ (instead of...
Read more >magento2 - TypeError: target.extend is not a function
Problem with using extend with model/address-converter. js is that this file return an object. If it would return an UI component than code ......
Read more >jQuery.extend() | jQuery API Documentation
The merge performed by $.extend() is not recursive by default; if a property of the first object is itself an object or array,...
Read more >extends - JavaScript - MDN Web Docs - Mozilla
The extends keyword is used in class declarations or class ... TypeError: Class extends value does not have valid prototype property 3
Read more >jQuery UI TypeError: e.widget.extend is not a function - YouTube
jQuery : jQuery UI TypeError : e.widget. extend is not a function [ Beautify Your Computer : https://www.hows.tech/p/recommended.html ] jQuery ...
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
I found the solution by doing this: in toastr.js (node_modules/toastr) I change the extend to Object.assign :
Did you find a way to make it work in repeatable manner such that anyy other team member, who does npm install won’t have this change manually? I am facing the same issue and your solution is the only one that’s relevant to my scenario.