traceur

How to mock dependencies for unit tests with ES6 Modules

扶醉桌前 提交于 2019-11-26 15:42:37
问题 I'm trying to fiddle with Ecmascript 6 modules using webpack + traceur to transpile to ES5 CommonJS, but I'm having trouble successfully unit testing them. I tried using Jest + traceur preprocessor, but the automocking and dependency names seem to get screwy, plus I can't seem to get sourceMaps to work with Jest and node-inspector debugging. Is there a better framework to unit test ES6 modules? 回答1: I've started employing the import * as obj style within my tests, which imports all exports

Override a setter, and the getter must also be overridden

我怕爱的太早我们不能终老 提交于 2019-11-26 09:58:46
问题 class AbstractClass { constructor() { } set property(value) { this.property_ = value; } get property() { return this.property_; } } class Subclass extends AbstractClass { constructor() { super(); } set property(value) { super.property = value; if (!(this.property_ instanceof SubclassAssociatedClass)) throw new TypeError(); } //get property() { // return super.property; //} } Override the set method of an attribute and it appears the get method must be overridden also, otherwise undefined is