diff --git a/packages/x-data-grid-pro/src/tests/dataSource.DataGridPro.test.tsx b/packages/x-data-grid-pro/src/tests/dataSource.DataGridPro.test.tsx
index ba0d21fcd5668..6f6622cbead11 100644
--- a/packages/x-data-grid-pro/src/tests/dataSource.DataGridPro.test.tsx
+++ b/packages/x-data-grid-pro/src/tests/dataSource.DataGridPro.test.tsx
@@ -277,26 +277,22 @@ describeSkipIf(isJSDOM)(' - Data source', () => {
describe('Error handling', () => {
it('should call `unstable_onDataSourceError` when the data source returns an error', async () => {
- const onDataSourceError = spy();
-
- const dataSource: GridDataSource = {
- getRows: () => {
- throw new Error('Could not fetch the data');
- },
- };
-
- render(
-
-
-
,
+ const onDataSourceErrorSpy = spy();
+ const { setProps } = render(
+ ,
);
+ expect(onDataSourceErrorSpy.callCount).to.equal(0);
+
+ setProps({ shouldRequestsFail: true });
+ act(() => {
+ apiRef.current.unstable_dataSource.fetchRows();
+ });
await waitFor(() => {
- expect(onDataSourceError.callCount).to.equal(1);
+ expect(onDataSourceErrorSpy.callCount).to.equal(1);
});
});
});