Reputation: 4686
I'm currently trying to implement simple tests for my JavaScript components and I am getting the error: TypeError: undefined is not a function
from my test.
This is erroring on this line within my class:
this.options = Object.assign({}, this.defaults, options);
this.defaults
is an object of default options and options
is currently an object with nothing in.
I am running the code from CLI using npm test
which resolves to this: mocha ./src/components/myComponent/myComponent.spec.js --compilers js:babel-register
Does anyone know why this error occurs?
Upvotes: 1
Views: 795
Reputation: 10460
Babel needs a plugin in order to transform Object.assign
, please try to install babel-plugin-transform-object-assign.
Upvotes: 1
Reputation: 242
What version of node are you running with? Object.assign won't be available throughout. You might want to use object-assign package
const assign = require('object-assign');
...
this.options = assign({}, this.defauts, options)
Upvotes: 0