Saturday, 15 January 2011

javascript - Polymer Unit Testing unreliable Platform.flush -



javascript - Polymer Unit Testing unreliable Platform.flush -

i have set testing framework polymer elements , have next convenience functions mocha, element polymer element tested in <iframe>:

this.ctx.set = function(callback) { callback.call(this, this.element); platform.flush(); homecoming this; }; this.ctx.then = function(callback) { settimeout(function() { callback.call(this, this.element); this.test.callback(); }.bind(this), 100); homecoming this; };

these used so:

(function() { 'user strict'; elementsuite('vca-colour-picker', function() { test('setting web value should reflected in rgb values', function(done) { this.set(function(element) { element.web = '#ffcc88'; }).then(function(element) { assert.equal(element.r, 255); assert.equal(element.g, 204); assert.equal(element.b, 136); }); }); }); }());

the settimeout depending on milliseconds specified fails occasionally. used unit testing polymer elements guide determine platform.flush , settimeout seems unreliable testing.

is there reliable way can create sure then function ran after polymer attribute changes have propagated?

javascript unit-testing polymer

No comments:

Post a Comment