Skip to content

Commit

Permalink
test: Fix timings test
Browse files Browse the repository at this point in the history
duration is  0 since no performance API is available
  • Loading branch information
eps1lon committed Mar 19, 2019
1 parent 6a0106f commit 317cb44
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions packages/enzyme-test-suite/test/ReactWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -759,13 +765,13 @@ describeWithDOM('mount', () => {

const wrapper = mount(<SomeComponent />);
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);
});
});

Expand Down

0 comments on commit 317cb44

Please sign in to comment.