Skip to content
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

[BUG] React component tests throw type error when passing null/undefined to component #29028

Closed
bethmaloney opened this issue Jan 17, 2024 · 0 comments · Fixed by #29031
Closed
Assignees
Labels

Comments

@bethmaloney
Copy link

bethmaloney commented Jan 17, 2024

System info

  • Playwright Version: [v1.41.0]
  • Operating System: [Windows 11]
  • Browser: [Chromium,]
  • Other info: Error did not occur in v1.40.1

Source code

Component

export const TestComponent = ({ value }: { value?: number }) => {
  return <div />;
};

Playwright test

test("PW Test", async ({ mount }) => {
  const component = await mount(<TestComponent value={undefined} />);
});

Steps

  • Run the test

Expected

Test should run and end successfully

Actual

Type error is thrown TypeError: Cannot read properties of undefined (reading '__pw_component_marker')

Running 1 test using 1 worker
  1) [chromium] › src\components\TestComponent.e2e.test.tsx:76:1 › PW Test ───────────

    Error: TypeError: Cannot read properties of undefined (reading '__pw_component_marker')

        at isComponent (http://localhost:3100/assets/index-bb8865af.js:191147:20)
        at __resolveProps (http://localhost:3100/assets/index-bb8865af.js:191188:14)
        at __pwResolveComponent (http://localhost:3100/assets/index-bb8865af.js:191178:11)
        at async window.playwrightMount (http://localhost:3100/assets/index-bb8865af.js:191243:3)
        at async eval (eval at evaluate (:226:30), <anonymous>:24:5)
        at async <anonymous>:252:30
        at isComponent (d:\test-repo\http:\localhost:3100\assets\index-bb8865af.js:191147:20)
        at __resolveProps (d:\test-repo\http:\localhost:3100\assets\index-bb8865af.js:191188:14)
        at __pwResolveComponent (d:\test-repo\http:\localhost:3100\assets\index-bb8865af.js:191178:11)
        at async window.playwrightMount (d:\test-repo\http:\localhost:3100\assets\index-bb8865af.js:191243:3)
        at async eval (d:\test-repo\eval at evaluate (:226:30), <anonymous>:24:5)
        at d:\test-repo\async <anonymous>:252:30
        at mount (d:\test-repo\node_modules\@playwright\experimental-ct-core\lib\mount.js:49:35)
        at d:\test-repo\src\components\TestComponent.e2e.test.tsx:77:27

  1 failed
    [chromium] › src\components\TestComponent.e2e.test.tsx:76:1 › PW Test ────────────

Additional Information

This also occurs for null values.

Omitting the undefined value as below and the test runs successfully

test("PW Test", async ({ mount }) => {
  const component = await mount(<TestComponent />);
});

Not sure if it's related to #29027

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants