'undefined' is not a function (evaluating Object.assign)
Issue description or question
I've a test failing where source file is using Object.assign with error message "TypeError: 'undefined' is not a function (evaluating Object.assign())"
I am using webpack
Wallaby.js configuration file
module.exports = function (wallaby) {
return {
"files": [
"src/**/*.ts"
],
"tests": [
"test/**/*Spec.ts"
],
"compilers": {
"**/*.ts": wallaby.compilers.typeScript({})
},
postprocessor: webpackPostprocessor,
bootstrap: function() {
window.__moduleBundler.loadTests();
}
}
};
Code editor or IDE name and version
WebStorm v11
OS name and version
Windows
Object.assign is a part of ES2015 and wallaby.js by default is using PhantomJs that doesn't support ES2015 (actually no browser fully supports it yet). You'll need to install and include a polyfill, for example babel-polyfill, as described here.
Alternatively, you may configure and use Headless Chrome or Electron test runner with wallaby.js, it supports the ES6 spec, so no polyfill is required.
Note that you'll need to do something similar in your production app if you intend to support browsers/devices without ES2015 support.
for people using Angular2, u can add { pattern: 'node_modules/es6-shim/es6-shim.js', instrument: false } in your wallaby configuration file to fix this issue.