Skip to content

[BUG] React component tests not passing Date prop values #29027

@leiit

Description

@leiit

System info

  • Playwright Version: v1.41.0, 1.42.0-alpha-jan-17-2024
  • Operating System: All
  • Browser: All
  • Other info: Works with v1.40.1 and below

Source code

const TestComponent = ({ date }: { date: Date }) => {
  console.log('date', date);

  return <span>{date.toLocaleDateString()}</span>;
};

export default TestComponent;
import { expect, test } from '@playwright/experimental-ct-react';
import TestComponent from './TestComponent';

test('can pass a Date object to the component', async ({ mount, page }) => {
  await mount(<TestComponent date={new Date('2000-06-01')} />);
  await expect(page.getByText('2000')).toBeInViewport();
});

Steps

  • Run the test

Expected

Component renders, Date objects were passed from the runner to the browser environment prior to v1.41.0.

Screenshot 2024-01-17 at 21 16 10

Actual

Empty object is passed from the runner.

Screenshot 2024-01-17 at 20 59 53

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions