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.

TypeError: $.extend is not a function

See original GitHub issue

Hi, 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', () => {
      .reply(200, dummy_coa);

    const store = mockStore({ coa: {} });
    let expectedAction = [{ type: FETCH_ALL_COA, payload: [{
    return store.dispatch(fetchAllCOA())
      .then(() => {

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:});
    }).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:closed
  • Created 6 years ago
  • Comments:7

github_iconTop GitHub Comments

Ahershelcommented, Jan 29, 2018

I found the solution by doing this: in toastr.js (node_modules/toastr) I change the extend to Object.assign :

function getOptions() {
   return Object.assign({}, getDefaults(), toastr.options);
shubmittalcommented, Apr 2, 2018

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.

Read more comments on GitHub >

github_iconTop 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 : ] jQuery ...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found