diff --git a/packages/ra-ui-materialui/src/field/DateField.spec.tsx b/packages/ra-ui-materialui/src/field/DateField.spec.tsx
index 4c854cc999f..08c9b0c34eb 100644
--- a/packages/ra-ui-materialui/src/field/DateField.spec.tsx
+++ b/packages/ra-ui-materialui/src/field/DateField.spec.tsx
@@ -37,6 +37,13 @@ describe('', () => {
expect(container.firstChild).toBeNull();
});
+ it('should return null when the record has an invalid type for the source', () => {
+ const { container } = render(
+
+ );
+ expect(container.firstChild).toBeNull();
+ });
+
it('should render a date', () => {
const { queryByText } = render(
{
+ if (value == null || value === '') return undefined;
+
+ return value instanceof Date
+ ? value
+ : typeof value === 'string' || typeof value === 'number'
+ ? new Date(value)
+ : undefined;
+ };
+ const date = parsedDate(value);
+
+ if (typeof date === 'undefined') {
return emptyText ? (