Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky test causing spurious drops in code coverage #1632

Merged
merged 3 commits into from
Aug 1, 2023
Merged

Fix flaky test causing spurious drops in code coverage #1632

merged 3 commits into from
Aug 1, 2023

Conversation

GLVSKiriti
Copy link
Contributor

@GLVSKiriti GLVSKiriti commented Aug 1, 2023

Which problem is this PR solving?

Short description of the changes

  • To remove the non determinism in the code

Signed-off-by: GLVS Kiriti <glvskiriti2003369@gmail.com>
@codecov
Copy link

codecov bot commented Aug 1, 2023

Codecov Report

Patch coverage has no change and project coverage change: +0.02% 🎉

Comparison is base (5489990) 95.99% compared to head (22c06df) 96.01%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1632      +/-   ##
==========================================
+ Coverage   95.99%   96.01%   +0.02%     
==========================================
  Files         242      242              
  Lines        7559     7559              
  Branches     1984     1984              
==========================================
+ Hits         7256     7258       +2     
+ Misses        303      301       -2     

see 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yurishkuro
Copy link
Member

could you please explain why this change works?

So that atleast once in the test if block will be executed

Signed-off-by: GLVS Kiriti <glvskiriti2003369@gmail.com>
@GLVSKiriti
Copy link
Contributor Author

GLVSKiriti commented Aug 1, 2023

could you please explain why this change works?

getViewedBounds: jest
.fn()
.mockReturnValueOnce({ start: 0.5, end: 0.6 })
.mockReturnValue({ start: 0, end: 1 }),

Here I am trying to execute if code block at least once . As previously getViewBounds function always returns {start:0,end:1} so always else block is executed in test

if (viewStart > 1 - viewEnd) {
longLabel = `${labelDetail} | ${label}`;
hintSide = 'left';
} else {
longLabel = `${label} | ${labelDetail}`;
hintSide = 'right';

@GLVSKiriti GLVSKiriti marked this pull request as ready for review August 1, 2023 15:00
@yurishkuro
Copy link
Member

two different mock returns are good if the function is guaranteed to be called multiple times in the test. Is it?

@GLVSKiriti
Copy link
Contributor Author

GLVSKiriti commented Aug 1, 2023

two different mock returns are good if the function is guaranteed to be called multiple times in the test. Is it?

Yes we are calling multiple times in the test file

const spanRow = shallow(<SpanBarRow {...props} span={span} />);
const refButton = spanRow.find(ReferencesButton);
expect(refButton.length).toEqual(1);
expect(refButton.at(0).props().tooltipText).toEqual('Contains multiple references');
});
it('render referenced to by single span', () => {
const span = Object.assign(
{
subsidiarilyReferencedBy: [
{
refType: 'CHILD_OF',
traceID: 'trace1',
spanID: 'span0',
span: {
spanID: 'span0',
},
},
],
},
props.span
);
const spanRow = shallow(<SpanBarRow {...props} span={span} />);

Indirectly for every shallow render getViewBounds function is called

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@yurishkuro yurishkuro changed the title Removal of non determinism in the code Fix flaky test causing spurious drops in code coverage Aug 1, 2023
@yurishkuro yurishkuro enabled auto-merge (squash) August 1, 2023 16:46
@yurishkuro yurishkuro merged commit f559122 into jaegertracing:main Aug 1, 2023
8 checks passed
@GLVSKiriti GLVSKiriti deleted the flakyTest branch August 1, 2023 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug] Flaky test causing spurious drops in code coverage
2 participants