์ค๋ ์ท ํ ์คํธ์ ํ๊ณ
ํด๋จผ ์๋ฌ
์ ํ๋ฆฌ์ผ์ด์ ์ ์ฝ๋๊ฐ ๊ณ์ ๋ณํ์ ๋ฐ๋ผ UI ๊ตฌ์กฐ๊ฐ ๋ณ๊ฒฝ๋๋ฉด ์ค๋ ์ท ํ ์คํธ๋ ์คํจํ๊ฒ ๋๊ณ , ๊ฐ๋ฐ์๋ ์๋ํ ๋ณํ์ด๋ ์ค๋ ์ท์ ์ ๋ฐ์ดํธ ํ๊ฒ ๋๋ค. ๊ทธ๋ฐ๋ฐ ์ด ๊ณผ์ ์ด ์์ฃผ ๋ง์ด ๋ฐ๋ณต๋๋ฉด์ ์ค๋ ์ท ํ ์คํธ ์คํจ์ ์์ธ์ ๋ฉด๋ฐํ ์ดํด๋ณด์ง ์๊ณ ๋จ์ํ ๋ณ๊ฒฝ๋ UI ๊ตฌ์กฐ ๋๋ฌธ์ผ๊ฑฐ๋ผ ์๊ฐํ๊ณ ์ฝ๊ฒ ์ ๋ฐ์ดํธ๋ฅผ ํด๋ฒ๋ฆฐ๋ค๋ฉด, ๋ฒ๊ทธ๋ฅผ ์ฐพ์ง ๋ชปํ๋ค๋ ํ ์คํธ ๋ณธ์ฐ์ ๊ธฐ๋ฅ์ ๋คํ์ง ๋ชปํ๊ฒ ๋๋ค.
UI ๋ณ๊ฒฝ์ฌํญ
jsDOM ์ค๋ ์ท์ DOM ํธ๋ฆฌ๋ฅผ ๋น๊ตํ๊ธฐ ๋๋ฌธ์ ๊ทธ๊ฒ ๋ฐ๋์ ์ฌ๋ฐ๋ฅธ ๋ ๋๋ง์ ๋ณด์ฅํ์ง ์๋๋ค. CSS ์์ฑ์ด ๋ณ๊ฒฝ๋๋ฉด ์ต๋ ํด๋น ์ปดํฌ๋ํธ์ ๋ ์ด์์์ด ์ฌ๋ฐฐ์น๋ ๋งํผ ํฐ ๋ณํ๊ฐ ๋ฐ์ํ ์ ์๋๋ฐ, ์ค๋ ์ท ํ ์คํธ์์๋ ๊ฐ์ DOM ๊ตฌ์กฐ๋ฅผ ๊ฐ์ง๊ธฐ ๋๋ฌธ์ ๋ณํ๋ฅผ ๊ฐ์งํด๋ผ ์ ์๋ค.
TDD ๋ถ์ ํฉ์ฑ
TDD ์ฌ์ดํด ๋ด์์ ์ค๋ ์ท ํ ์คํธ๋ฅผ ์ํํ ๊ฒฝ์ฐ ์ํฉ์ ๋ง๊ฒ ์ค๋ ์ท์ ์ ๋ฐ์ดํธ ํ์ง ์๋๋ค๋ฉด ํ ์คํธ๊ฐ ํญ์ ์คํจํ๊ฒ ๋๋ค. ๊ทธ๋์ ๊ทธ ์ฌ์ดํด ์์ ๊ฐ๋ฐ์๊ฐ ์ ๋ฐ์ดํธ ์ฌ๋ถ๋ฅผ ํ๋จํ๊ธฐ ์ํ ๊ณผ์ ์ด ์ถ๊ฐ๋์ด TDD ์ฌ์ดํด๊ณผ ๋ง์ง ์๋ ๋ฐฉ์์ผ๋ก ํ ์คํธ๋ฅผ ์์ฑํ๊ฒ ๋๋ค.
Don't Rely on Snapshot Tests #
Ever since I started working with React in 2016 Iโve had only one situation in which snapshot tests have caught a problem in my components. A call to
new Date()without an argument had slipped and it always defaulted to the current date.Besides this, snapshots have only been a cause for failed builds when a component is changed. The usual workflow is to make a change to the component, see that snapshots are failing, update them and proceed.
Donโt get me wrong, they are a good sanity check but they are not a replacement for good component level tests. I avoid even creating them anymore.
- Alex Kondov, Tao of React
์๊ฐ์ ํ๊ท ํ ์คํธ
์์ Alex Kondov์ ์ธ๊ธ์ฒ๋ผ ํ๋ก ํธ์๋์์ ์ค๋ ์ท ํ ์คํธ๋ ๊ฑฐ์ ์ฌ์ฉ๋์ง ์๋๋ค๊ณ ํ๋ค. ๊ทธ๋์ ์ด ํ๊ณ๋ฅผ ๊ทน๋ณตํ๊ณ ์คํ์ผ๊ณผ ๋ ์ด์์์ ๋ํ ๋ณ๊ฒฝ์ฌํญ๊น์ง ๊ฐ์งํ ์ ์๋ ๋ฐฉ๋ฒ์ธ ์๊ฐ์ ํ๊ท ํ ์คํธ๋ฅผ ์ฌ์ฉํ๋ค.
