-
Notifications
You must be signed in to change notification settings - Fork 467
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
[tests] Remove enzyme from QualityMetrics tests #1684
Conversation
Signed-off-by: Freedisch <freeproduc@gmail.com>
I Will keep migrating other files |
@Freedisch Are tests working fine locally? I think you might haven't generated the snapshots. |
@anshgoyalevil, I just noticed, I will update it with the shallow func u created, previously |
Signed-off-by: Freedisch <freeproduc@gamil.com>
Signed-off-by: Freedisch <freeproduc@gamil.com>
Mirgation to RLT with There is an expected behavior with snapshots with |
|
||
import CountCard from './CountCard'; | ||
import shallow from '../../utils/ReactShallowRenderer.test'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can the last two tests be modified to assert specific things on the output instead of using shallow
? This seems like a simply component to test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I'm on it
Signed-off-by: Freedisch <freeproduc@gamil.com>
Signed-off-by: Freedisch <freeproduc@gamil.com>
@yurishkuro, I have updated both tests and currently, they no longer snapshots |
const { getByText } = render(<CountCard count={count} title={title} examples={examples} />); | ||
|
||
const countElement = getByText('108'); | ||
const titleElement = getByText('Test Title'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
simplify
const titleElement = getByText('Test Title'); | |
expect(getByText(title)).toBeInTheDocument(); |
this makes the test easier to read
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it
@anshgoyalevil do you mind reviewing this? |
@yurishkuro Sure. Would be happy to review 🚀 |
}); | ||
|
||
it('renders header when props.bannerText is a string', () => { | ||
expect(shallow(<BannerText bannerText="foo text" />)).toMatchSnapshot(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since toMatchSnapshot()
is no longer used, the snapshots created for this test needs to be purged.
You can use the command yarn test --updateSnapshot
for that.
}} | ||
/> | ||
) | ||
).toMatchSnapshot(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Snapshots need to be purged for this too. Otherwise, the tests would pass, but CI will fail.
}); | ||
|
||
it('renders header when props.bannerText is a string', () => { | ||
expect(shallow(<BannerText bannerText="foo text" />)).toMatchSnapshot(); | ||
const { getByText } = render(<BannerText bannerText="foo text" />); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use most of these functions using the screen
object from @testing-library/react
.
Example,
render(<BannerText bannerText="foo text" />);
expect(screen.getByText('foo text')).toBeInTheDocument();
Same goes for other such usages as well
Signed-off-by: Freedisch <freeproduc@gmail.com>
Signed-off-by: Freedisch <freeproduc@gmail.com>
@anshgoyalevil, updated changes |
packages/jaeger-ui/src/components/QualityMetrics/CountCard.test.js
Outdated
Show resolved
Hide resolved
render(<CountCard count={count} title={title} />); | ||
|
||
expect(screen.getByText('108')).toBeInTheDocument(); | ||
expect(screen.getByText('Test Title')).toBeInTheDocument(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect(screen.getByText('Test Title')).toBeInTheDocument(); | |
expect(screen.getByText(title)).toBeInTheDocument(); |
expect(screen.getByText('108')).toBeInTheDocument(); | ||
expect(screen.getByText('Test Title')).toBeInTheDocument(); | ||
expect(screen.getByText('Examples')).toBeInTheDocument(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the same constants, not literal strings
Note: this description is inaccurate, this issue does not resolve the issue completely, it's a partial solution.
I am changing it to "part of ..." |
Codecov ReportPatch and project coverage have no change.
Additional details and impacted files@@ Coverage Diff @@
## main #1684 +/- ##
=======================================
Coverage 96.01% 96.01%
=======================================
Files 241 241
Lines 7560 7560
Branches 1985 1985
=======================================
Hits 7259 7259
Misses 301 301 ☔ View full report in Codecov by Sentry. |
Which problem is this PR solving?
Description of the changes
Currently I migrated 3 files
QualityMetrics/BannerText.test.js
QualityMetrics/CountCard.test.js
How was this change tested?
Checklist
jaeger
:make lint test
jaeger-ui
:yarn lint
andyarn test