-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[charts] Migrate from sinon to Vitest mocking utilities for x-charts* packages #20444
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
Conversation
Co-authored-by: bernardobelchior <12778398+bernardobelchior@users.noreply.github.com>
|
Deploy preview: https://deploy-preview-20444--material-ui-x.netlify.app/ Bundle size report
|
|
@copilot prefer Also, run |
Co-authored-by: bernardobelchior <12778398+bernardobelchior@users.noreply.github.com>
Done in c953fe1. Changed all occurrences of Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot Fix types: |
Co-authored-by: bernardobelchior <12778398+bernardobelchior@users.noreply.github.com>
Fixed in 9c511ab. Added non-null assertions ( Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
CodSpeed Performance ReportMerging #20444 will not alter performanceComparing Summary
|
JCQuintas
left a comment
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.
If you are planning to add this all other packages, it would be nice to have a eslint rule to prevent us from using sinon again in new tests :)
| ]); | ||
|
|
||
| expect(onItemClick.lastCall.args[1]).to.deep.equal({ | ||
| expect(onItemClick.mock.calls.at(-1)![1]).to.deep.equal({ |
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.
We could replace all these mock.calls.at(-1) with mock.lastCall, but optional
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.
@copilot does mock.lastCall work here? If so, update it all over this PR
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.
Yes, mock.lastCall works here. Replaced all occurrences in 7c4939c.
Isn't removing the dependency enough? That's what I was imagining. |
Co-authored-by: bernardobelchior <12778398+bernardobelchior@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
I don't think it will in our case, |
| ); | ||
|
|
||
| expect(onRenderSpy.lastCall.firstArg).to.equal('line'); | ||
| expect(onRenderSpy.mock.lastCall![0]).to.equal('line'); |
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.
These should probably be optional access instead
| expect(onRenderSpy.mock.lastCall![0]).to.equal('line'); | |
| expect(onRenderSpy.mock.lastCall?.[0]).to.equal('line'); |
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.
@copilot use ?. instead of ! when accessing potentially null or undefined values
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.
Done in dbb147c. Changed mock.lastCall! to mock.lastCall?. across all files.
…k.lastCall Co-authored-by: bernardobelchior <12778398+bernardobelchior@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Cherry-picks changes from #20352 to migrate x-charts packages from sinon to Vitest mocking utilities.
Changes
spy()/sinon.spy()withvi.fn().callCountwith.mock.calls.length.lastCall.args[N]with.mock.lastCall?.[N].firstCall?.args[N]with.mock.calls[0]?.[N].getCall(N).firstArgwith.mock.calls[N][0].resetHistory()with.mockClear()Files Modified
x-charts:
BarChart/checkClickEvent.test.tsxChartsLocalizationProvider/ChartsLocalizationProvider.test.tsxLineChart/checkClickEvent.test.tsxPieChart/checkClickEvent.test.tsxRadarChart/RadarChart.test.tsx,RadarChart/checkClickEvent.test.tsxScatterChart/checkClickEvent.test.tsxinternals/animation/useAnimate.test.tsxinternals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.axisHighlight.test.tsxx-charts-premium:
ChartsRenderer/ChartsRenderer.test.tsxx-charts-pro:
ChartZoomSlider/ChartZoomSlider.test.tsxFunnelChart/checkClickEvent.test.tsxLineChartPro/LineChartPro.zoom.test.tsxScatterChartPro/ScatterChartPro.zoom.test.tsxBarChartPro/BarChartPro.zoom.test.tsxinternals/plugins/useChartProZoom/ZoomInteractionConfig.test.tsxI have followed (at least) the PR section of the contributing guide.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.