I am wondering how can I use the spy / stub function on Jasmine if I use ES6 import / export with babel?
import MobileDetect from 'mobile-detect'; it('should spy MobileDetect', () => { MobileDetect = jasmine.createSpy('MobileDetect'); });`
The first problem is that I cannot rewrite a read-only module
Module build error: SyntaxError: /Users/oleg/projects/rp/popup/lib/spec/popup.spec.js: "MobileDetect" is read-only
it('should spy MobileDetect', () => { console.log(MobileDetect.prototype.constructor === MobileDetect); //true spyOn( MobileDetect.prototype, 'constructor' ); console.log(MobileDetect.prototype.constructor === MobileDetect); //false });`
I tried this approach, but it doesnβt work either ... MobileDetect.prototype.constructor is a spy, but MobileDetect does not work directly.
What do you think of this problem?
javascript ecmascript-6 jasmine spy es6-module-loader
dedirot
source share