From 317cb440d8dbb196a07c201778d1f74ab099fc55 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Tue, 19 Mar 2019 09:28:25 +0100 Subject: [PATCH] test: Fix timings test duration is 0 since no performance API is available --- .../enzyme-test-suite/test/ReactWrapper-spec.jsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/enzyme-test-suite/test/ReactWrapper-spec.jsx b/packages/enzyme-test-suite/test/ReactWrapper-spec.jsx index 60ba04e38..2dd462fbb 100644 --- a/packages/enzyme-test-suite/test/ReactWrapper-spec.jsx +++ b/packages/enzyme-test-suite/test/ReactWrapper-spec.jsx @@ -747,7 +747,13 @@ describeWithDOM('mount', () => { expect(handleRender.args[1][1]).to.equal('update'); }); - it.skip('measures timings', () => { + it('measures timings', () => { + /** + * test environment has no access to the performance API at which point + * the profiling API has to fallback to Date.now() which isn't precise enough + * which results in 0 duration for these simple examples most of the time. + * With performance API it should test for greaterThan(0) instead of least(0) + */ const handleRender = sinon.spy(); function SomeComponent() { return ( @@ -759,13 +765,13 @@ describeWithDOM('mount', () => { const wrapper = mount(); expect(handleRender).to.have.property('callCount', 1); - expect(handleRender.args[0][2]).to.be.greaterThan(0); - expect(handleRender.args[0][3]).to.be.greaterThan(0); + expect(handleRender.args[0][2]).to.be.least(0); + expect(handleRender.args[0][3]).to.be.least(0); wrapper.setProps({ unusedProp: true }); expect(handleRender).to.have.property('callCount', 2); - expect(handleRender.args[1][2]).to.be.greaterThan(0); - expect(handleRender.args[1][3]).to.be.greaterThan(0); + expect(handleRender.args[1][2]).to.be.least(0); + expect(handleRender.args[1][3]).to.be.least(0); }); });