How to mock useRef using playwright component testing ?

hello I'm writing test for a component with ref. I'd like to mock the ref element and change some properties but have no idea how to. Any suggestions? import { test, expect } from "@playwright/experimental-ct-react"; import { useState } from "react"; import { useRef } from "react"; import Main from "./index"; test.use({ viewport: { width: 500, height: 500 } }); test("should work", async ({ mount }) => { const refMain = useRef(); const refFooter = useRef(); const refMenuButton = useRef(); const [mainPostion, setMainPostion] = useState(startMainPostion); const refContainerForMainFooter = useRef({ refMain, refFooter, refMenuButton, }); const component = await mount( <Main setMainPostion={setMainPostion} theme='light' ref={ref} /> ); // await expect(component).toContainText('DAMAN'); });
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server