Skip to content

Commit

Permalink
Make test-resource.js not flaky (#20514)
Browse files Browse the repository at this point in the history
Remove call count expectations on getRect method call which is the culprit of the flakiness of the tests mentioned. This should be fine as it doesn't take away from what's being primarily tested as it occurs in the afterEach call. Note that this is not a permanent fix but a temporary one to alleviate the flakiness. I will keep #16124 open.

Tested locally and ran it several times in saucelabs.
  • Loading branch information
alabiaga authored Feb 13, 2019
1 parent 4a7282f commit e13a531
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/unit/test-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ describe('Resources discoverWork', () => {
VisibilityState.VISIBLE
);
viewportMock.expects('getRect').returns(
layoutRectLtwh(0, 0, 300, 400)).once();
layoutRectLtwh(0, 0, 300, 400));
resource1.isBuilt = () => false;
const mediaSpy = sandbox.stub(resource1.element, 'applySizesAndMediaQuery');
expect(resource1.hasBeenMeasured()).to.be.false;
Expand All @@ -1153,7 +1153,7 @@ describe('Resources discoverWork', () => {
VisibilityState.VISIBLE
);
viewportMock.expects('getRect').returns(
layoutRectLtwh(0, 0, 300, 400)).once();
layoutRectLtwh(0, 0, 300, 400));

resources.discoverWork_();

Expand All @@ -1170,7 +1170,7 @@ describe('Resources discoverWork', () => {
VisibilityState.VISIBLE
);
viewportMock.expects('getRect').returns(
layoutRectLtwh(0, 0, 300, 400)).once();
layoutRectLtwh(0, 0, 300, 400));

resources.discoverWork_();

Expand All @@ -1193,7 +1193,7 @@ describe('Resources discoverWork', () => {
resources.relayoutAll_ = false;
resources.relayoutTop_ = 1000;
viewportMock.expects('getRect').returns(
layoutRectLtwh(0, 0, 300, 400)).once();
layoutRectLtwh(0, 0, 300, 400));

resources.discoverWork_();

Expand All @@ -1211,7 +1211,7 @@ describe('Resources discoverWork', () => {
);
resources.prerenderSize_ = 1;
viewportMock.expects('getRect').returns(
layoutRectLtwh(0, 0, 300, 1009)).once();
layoutRectLtwh(0, 0, 300, 1009));

resources.discoverWork_();

Expand All @@ -1226,7 +1226,7 @@ describe('Resources discoverWork', () => {
);
resources.prerenderSize_ = 0;
viewportMock.expects('getRect').returns(
layoutRectLtwh(0, 0, 300, 400)).once();
layoutRectLtwh(0, 0, 300, 400));

resources.discoverWork_();

Expand All @@ -1242,7 +1242,7 @@ describe('Resources discoverWork', () => {
VisibilityState.VISIBLE
);
viewportMock.expects('getRect').returns(
layoutRectLtwh(0, 0, 300, 400)).atLeast(1);
layoutRectLtwh(0, 0, 300, 400));

const resource1MeasureStub = sandbox.stub(resource1, 'measure').callsFake(
resource1.measure.bind(resource1));
Expand Down Expand Up @@ -1452,7 +1452,7 @@ describe('Resources discoverWork', () => {
VisibilityState.VISIBLE
);
viewportMock.expects('getRect').returns(
layoutRectLtwh(0, 0, 300, 400)).once();
layoutRectLtwh(0, 0, 300, 400));
const setInViewport = sandbox.spy(resource1, 'setInViewport');
const schedule = sandbox.spy(resources, 'scheduleLayoutOrPreload_');

Expand Down Expand Up @@ -2236,7 +2236,7 @@ describe('Resources changeSize', () => {

viewportMock.expects('getRect').returns({
top: 10, left: 0, right: 100, bottom: 210, height: 200,
}).once();
});
resource1.layoutBox_ = {top: -1200, left: 0, right: 100, bottom: -1100,
height: 100};
resource2.layoutBox_ = {top: -1300, left: 0, right: 100, bottom: -1200,
Expand Down Expand Up @@ -2468,7 +2468,7 @@ describe('Resources changeSize', () => {

beforeEach(() => {
viewportMock.expects('getRect').returns(
{top: 0, left: 0, right: 100, bottom: 10000, height: 200}).atLeast(1);
{top: 0, left: 0, right: 100, bottom: 10000, height: 200});
resource1.layoutBox_ = resource1.initialLayoutBox_ =
layoutRectLtwh(0, 10, 100, 100);
});
Expand Down

0 comments on commit e13a531

Please sign in to comment.