我目前正在尝试为我的JavaScript组件执行简单的测试,并从我的测试中得到错误:TypeError: undefined is not a function
。摩卡ES6 Babel“TypeError:undefined不是函数”
这示数上我的课中这一行:
this.options = Object.assign({}, this.defaults, options);
this.defaults
是默认选项的对象和options
是目前没有一个对象
我从运行代码CLI使用npm test
这可以解决这个问题:mocha ./src/components/myComponent/myComponent.spec.js --compilers js:babel-register
有谁知道为什么会出现这个错误?
也许你需要安装[babel-plugin-transform-object-assign](https://babeljs.io/docs/plugins/transform-object-assign/) –
@IsmailRBOUH - 这个工作!谢谢,你能写这个作为答案,我会投票吗? – 30secondstosam
答复已添加;)欢迎您,祝您好运。 –