karma-phantomjs-launcher icon indicating copy to clipboard operation
karma-phantomjs-launcher copied to clipboard

Why does this third party module call work with chrome-launcher, but not phantomjs-launcher?

Open fingermark opened this issue 9 years ago • 0 comments

I'm using date-fp and am making a calling D.parse("2015-01-01"). In chrome-launcher, this works fine. In my browser this works fine. In phantomjs-launcher, I get an empty Date object returned, which is causing subsequent calls that rely on the returned object to fail.

Any ideas why this is happening?

Third party module:

'use strict';
export default (...args) => new Date(...args);

Webpack code that PhatomJS and Karma sees:

function(module, exports) {

    'use strict';
    Object.defineProperty(exports, '__esModule', {
      value: true
    });
    var _bind = Function.prototype.bind;

    exports['default'] = function () {
      for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
        args[_key] = arguments[_key];
      }

      return new (_bind.apply(Date, [null].concat(args)))();
    };

    module.exports = exports['default'];

} 

I've tried both ./node_modules/phantomjs-polyfill/bind-polyfill.js and karma-phantomjs-shim.

fingermark avatar Nov 17 '15 18:11 fingermark