728x90
๋ฐ์ํ
๐ console.log() ๋ช ๋ น๋ฌธ์ด ๋ธ๋ผ์ฐ์ ์ ์ถ๋ ฅ์ ์ค์ผ์ํค๋ ๊ฒ์ฒ๋ผ ๋๋ฒ๊ทธ ๋ช ๋ น๋ฌธ๋ ํ ์คํธ๋ฅผ ์ค์ผ์ํต๋๋ค. ์ค์ ๋ก ํ ์คํธ๋ฅผ ๋๋ฒ๊ทธํ๊ณ ์ถ์ ๋ ๋ช ๋ น๋ฌธ์ ์ฌ์ฉํด์ผ ํ์ง๋ง ์ฝ๋๋ฒ ์ด์ค๋ก ํธ์ํด์๋ ์ ๋ฉ๋๋ค.
screen.debug(element)
ํด๋น ํ ์คํธ์์ ์์ฑํ element๊ฐ ํ๋ฉด, DOM์์ ์ด๋ป๊ฒ ๋ณด์ผ์ง ํ ์คํธ ์ถ๋ ฅ
- ์ฌ์ฉ ํ๋ฉด
screen.debug(screen.getByText("Grand total: $", { exact: false }));
- ์ถ๋ ฅ ํ๋ฉด
console.log
<h2>
Grand total:
$0.00
</h2>
at logDOM (node_modules/@testing-library/react/node_modules/@testing-library/dom/dist/pretty-dom.js:87:13)
logRoles(HTMLElement)
DOM์ ์ด๋ค ์ญํ ์ด ์๋์ง ํ์ธํ ์ ์์ด ์ญํ ๋ก ๊ฒ์ ์ ์ ์ฉํ๊ฒ ์ฌ์ฉ
- ์ฌ์ฉ ํ๋ฉด
const { container } = render(<App />);
logRoles(container);
//App ๋ด๋ถ์ Vanilla Button ๊ฒ์ ์ spinbutton ์ญํ ์ ํ์ธ ํ ๊ฒ์์ ์ฌ์ฉ
const vanillaButton = await screen.findByRole("spinbutton", {name: "Vanilla",});
- ์ถ๋ ฅ ํ๋ฉด
console.log
spinbutton:
Name "Vanilla":
<input
class="form-control"
id="Vanilla-count"
type="number"
value="0"
/>
--------------------------------------------------
at logRoles (node_modules/@testing-library/react/node_modules/@testing-library/dom/dist/role-helpers.js:212:20)
728x90
๋ฐ์ํ
'React > Jest' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Jest Warning: wrapped in act(...). (0) | 2023.06.19 |
---|---|
JEST Custom Render (0) | 2023.06.16 |
Jest ์ํ๋ ํ ์คํธ๋ง ์คํ (0) | 2023.06.15 |
JEST Mock Service Worker ํ ์คํธ ๋ด๋ถ ์ฌ์ฉ (0) | 2023.06.15 |
JEST Mock Service Worker ์ค์ ๋ฐ ๊ธฐ๋ณธ ์ฌ์ฉ (0) | 2023.06.15 |