![](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbBnvTW%2FbtsJhTb2U5i%2FxW2hNeJgeqlBP3Cfk4IGbK%2Fimg.png)
์๋ฌ ๋ฐ์react-router-dom๋ฅผ ์ฌ์ฉํ๋ ์ฝ๋์ playwright ํ ์คํธ ์ค ์๋์ ๊ฐ์ด useNavigate ๊ด๋ จ ์๋ฌ๊ฐ ๋ฐ์ํ์ต๋๋ค. ๋จ์ ํด๊ฒฐuseNavigate๋ react-router-dom ์ ํ ์ผ๋ก ์์นญํด๋ณด๋ MemoryRouter ๋ก ๊ฐ์ธ์ฃผ๋ฉด ๋๋ค๊ณ ํฉ๋๋ค. const component = await mount( , { hooksConfig } ); ์ด๋ ๊ฒ mount ์์ ๋จ์ํ ๊ฐ์ธ๋ ์์ผ๋ก ํด๊ฒฐํ ์๋ ์๊ฒ ์ง๋ง, ์ด ๋ถ๋ถ์ ๊ณตํตํ ํ ์ ์์ต๋๋ค. ๊ณตํตํ ์๋ 1import { MemoryRouter } from 'react-router-dom';import { AuthContext } from '@contexts';export const TE..
vite ํ๋ก์ ํธ์์ playwright ๋ฅผ ์ค์ ํ์ ๋, typecheck ๋ฅผ ๋๋ฆฌ๋ฉด spec.tsx ์์ ํ์ ๊ด๋ จ ์๋ฌ๊ฐ ๋๋ค. ์ด ๋๋ `@playwright/test` ํจํค์ง๋ฅผ ์ค์นํด์ tsconfig์ compilerOptions.types ํ๋์ ์ถ๊ฐํด์ฃผ๋ฉด ๋๋ค.{ "compilerOptions": { "types": ["node", "vite/client", "jest", "@testing-library/jest-dom", "@playwright/test"], }}
Comment