250x250
๋ฐ˜์‘ํ˜•
arkhyeon
arkhyeon
arkhyeon
์ „์ฒด ๋ฐฉ๋ฌธ์ž
์˜ค๋Š˜
์–ด์ œ
  • ๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ (88)
    • Spring (5)
    • Java (4)
    • React (25)
      • TypeScript (6)
      • JavaScript (1)
      • Jest (9)
    • NEXT (8)
    • SQL (1)
    • React native (1)
    • CSS (3)
    • Web (1)
    • Git (3)
    • ETC (6)
    • ๋น…๋ฐ์ดํ„ฐDB (8)
    • Docker (4)
    • Tool (1)

๋ธ”๋กœ๊ทธ ๋ฉ”๋‰ด

  • ํ™ˆ
  • ํƒœ๊ทธ
  • ๋ฐฉ๋ช…๋ก

๊ณต์ง€์‚ฌํ•ญ

์ธ๊ธฐ ๊ธ€

ํƒœ๊ทธ

  • usetransition
  • react spring websocket
  • react jest
  • jest
  • react typescript
  • kudu
  • react loading
  • node WebSocket
  • react usetransition
  • react
  • react websocket
  • HIVE
  • docker tomcat
  • websocket
  • javascript wss
  • websocket server
  • WSS
  • react19
  • javasciprt websocket
  • Spring WebSocket

์ตœ๊ทผ ๋Œ“๊ธ€

์ตœ๊ทผ ๊ธ€

ํ‹ฐ์Šคํ† ๋ฆฌ

hELLO ยท Designed By ์ •์ƒ์šฐ.
arkhyeon

arkhyeon

React/Jest

Jest Debugging Tips

2023. 6. 19. 17:44
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
    'React/Jest' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€
    • Jest Warning: wrapped in act(...).
    • JEST Custom Render
    • Jest ์›ํ•˜๋Š” ํ…Œ์ŠคํŠธ๋งŒ ์‹คํ–‰
    • JEST Mock Service Worker ํ…Œ์ŠคํŠธ ๋‚ด๋ถ€ ์‚ฌ์šฉ
    arkhyeon
    arkhyeon

    ํ‹ฐ์Šคํ† ๋ฆฌํˆด๋ฐ”