All Articles

Cypress + Travis + Webpack

  • Cypress๋ผ๋Š” ํˆด๋กœ Integration test๋ฅผ ๋ถ™์ด๊ณ  ์‹ถ์€๋ฐ, ๊ธฐ์™• ํ•˜๋Š”๊น€์— Travis CI์—์„œ๋„ ํ…Œ์ŠคํŠธ๋ฅผ ๋Œ๋ฆฌ๊ณ  ์‹ถ์Œ
  • ์นœ์ ˆํ•˜๊ฒŒ ์„ค๋ช…์„œ๋ฅผ ๋”ฐ๋ผ๊ฐ€๋ฉด ๋  ๊ฒƒ ๊ฐ™์ง€๋งŒ, ์ €๊ฑด Cypress๋ฅผ ๋Œ๋ฆฌ๋Š” ์–˜๊ธฐ๊ณ  Cypress๊ฐ€ ํ…Œ์ŠคํŠธํ•  ์›น์‚ฌ์ดํŠธ๋Š” ๋„์›Œ์ง€์ง€ ์•Š์Œ
  • ๋‹ค๋ฅธ ์˜ˆ์ œ๋ฅผ ๋ณด๋ฉด ๋ฐฑ๊ทธ๋ผ์šด๋“œ ํ”„๋กœ์„ธ์Šค๋กœ npm start๋ฅผ ํ•ด์ฃผ๋Š”๋ฐ ์—ฌ๊ธฐ์„œ npm start๋Š” dev server๊ฐ€ ์•„๋‹ˆ๋ผ ์ด๋ฏธ ๋นŒ๋“œ๋œ ์• ๋ฅผ ์„œ๋น™๋งŒ ํ•ด์ฃผ๋Š” http-server๋ฅผ ๋„์šฐ๋Š” ์Šคํฌ๋ฆฝํŠธ์ž„์— ์œ ์˜ํ•ด์•ผ ํ•œ๋‹ค.
    before_script:
    - npm start -- --silent &
  • webpack dev server ๋“ฑ์„ ๋„์šฐ๋ฉด ๋นŒ๋“œ๊ฐ€ ์™„๋ฃŒ๋˜์„œ ์›น์•ฑ์„ ์„œ๋น™ํ•˜๊ธฐ ์ด์ „์— Cypress ํ…Œ์ŠคํŠธ๊ฐ€ ์‹œ์ž‘๋˜์„œ ๋‹ค ๊นจ์ง„๋‹คใ…œใ…œ. index.html์ด ๋นˆ ํŽ˜์ด์ง€์ธ๋ฐ ๋ฌด์Šจ ํ…Œ์ŠคํŠธ๋ฅผ ํ•˜๊ฒ ์–ด. ์ด ๋ฌธ์ œ ๋•Œ๋ฌธ์— wait-on ์ด๋ผ๋Š” ํŒจํ‚ค์ง€๋„ ์จ๋ณด๊ณ  ์ด๋Ÿฐ์ €๋Ÿฐ ์‹œ๋„๋ฅผ ๋งŽ์ด ํ–ˆ๋Š”๋ฐ, ๊ฒฐ๊ตญ ๋นŒ๋“œ๋ฅผ ํ•˜๊ณ  ์ •์ ํŒŒ์ผ์„ ํ˜ธ์ŠคํŒ…ํ•ด์„œ ๊ทธ ์ฃผ์†Œ๋กœ ํ…Œ์ŠคํŒ…์„ ์ง„ํ–‰ํ•˜๋Š” ๋ฐฉ์‹์„ ํƒํ–ˆ๋‹ค.
  • ์ƒ๊ฐํ•ด๋ณด๋ฉด ์ด๊ฒŒ ์ข€ ๋” ์‹ค์ œ ํ™˜๊ฒฝ์ด๋ž‘ ๊ฐ€๊นŒ์šฐ๋‹ˆ๊นŒ ๊ฐœ๋ฐœ์„œ๋ฒ„๋กœ ํ…Œ์ŠคํŒ…์ด ๊ฐ€๋Šฅํ–ˆ์–ด๋„ ์ด๋ ‡๊ฒŒ ํ•˜๋Š”๊ฒŒ ๋งž๋‹ค.
  • ๊ฐœ์ธ์ ์œผ๋กœ๋Š” ๊ฐ€๋ณ๊ฒŒ ์ •์ ํŒŒ์ผ์„ ์„œ๋น™ํ•  ๋•Œ serve๋ฅผ ๋” ์ข‹์•„ํ•ด์„œ ์ตœ์ข…์ ์œผ๋กœ ์ด๋ ‡๊ฒŒ ์ƒ๊ธด .travis.yml์„ ์ž‘์„ฑํ–ˆ๋‹ค.
    before_script:
    - yarn build # ์ด๋Ÿฌ๋ฉด dist์— index.html ๋“ฑ๋“ฑํ•ด์„œ ์ƒ๊น€
    - serve -s dist &
    script:
    - cypress run --record

Published Sep 9, 2018

If I keep marking the dots, someday they will ๐Ÿ”—๐Ÿ”—