ããã«ã¡ã¯ããªãã¡ã¯ã¿ãªã³ã°ã大好ããªããã³ãã¨ã³ãããããæ¢ æ´¥ã§ãã
èªä¿¡ãæã£ã¦ãªãã¡ã¯ã¿ãªã³ã°ããã«ã¯ä¿¡é ¼ã§ããèªåãã¹ããå¿
è¦ã§ãããã
ãããä¿¡é ¼ã§ããèªåãã¹ãã¨ã¯ãªãã ããï¼ã©ãæ¸ããããããã ããï¼ã¨èãã¦ãã¾ããã
ã¨ãã«ã³ã³ãã¼ãã³ããå«ã UI ãã¹ãã«å¯¾ãã¦ã®æ©ã¿ãå¼·ãã£ãã§ãã
ãããªã¨ãã«åºä¼ã£ãã®ã Testing JavaScript ã§ãã
ãã®è¨äºã§ã¯ãã® Testing JavaScript ã®ç´¹ä»ããããã¨æãã¾ãã
Testing JavaScript ã¨ã¯
Testing JavaScript 㯠PayPal ã®ã¨ã³ã¸ãã¢ã§ãã Kent C. Dodds ã«ãã£ã¦ä½æãããææã§ãã
ãã¼ã¸ãéãã¦ããç®ã«é£ã³è¾¼ãã§ãããã¹ãã£ã³ã°ãããã£ã¼ãç¹å¾´çã§ããã
Testing JavaScript ã§ã¯ãããã«è¨ããã¦ãã Static, Unit Test, Integration Test, End to End Test ããããã®æ¹æ³ãå¦ã¶ããã«å
¨é¨ã§ 8 ã¤ã®ã³ã¼ã¹ãç¨æããã¦ãã¾ãã
ããã§ã¯åã³ã¼ã¹å
容ã¨å®éã«ãã£ã¦ã¿ãææ³ãè¦ã¦ããã¾ãããã
Fundamentals of Testing in JavaScript
ãã¹ããã¬ã¼ã ã¯ã¼ã¯ãã©ããã£ã¦ãã¹ããå®è¡ãããã¨ã©ã¼ãåºåãã¦ããã®ãæ°ã«ãªãã¾ãããï¼
ä½ããã¦ããã®ãç¥ãããã«ã¯ä½ãã®ãä¸çªï¼
ã¨ããããã§ããã®ã³ã¼ã¹ã§ã¯ã·ã³ãã«ãªãã¹ããã¬ã¼ã ã¯ã¼ã¯ãèªä½ãã¾ãã
ã·ã³ãã«ã¨ã¯ããå¿ è¦ãªæ©è½ã¯ããã£ã¦ããã®ã§ãæ®æ®µä½¿ã£ã¦ãããã¹ããã¬ã¼ã ã¯ã¼ã¯ãã©ããããã¨ããã¦ããã®ãæ³åãããããªãã¾ããã
Static Analysis Testing JavaScript Applications
ã¢ããªã±ã¼ã·ã§ã³ã¨ã¯ãªãã¨ãèããã®ã§ãtypo ããããåã«åããªãå¤ããããã ãã§ç°¡åã«å£ãã¦ãã¾ãã¾ãã
ãããã£ãä¸å
·åãèµ·ãããªãããã«ç¶²ç¾
çãªãã¹ããæ¸ãã¦ãããã§ãããæ£ç´è¨ã£ã¦å´åã«è¦åããªãã§ãããã
ã§ããã°ãããã£ããã¨ã¯ã³ã¼ããæ¸ãã¦ããã¨ãã«èªåçã«ãã§ãã¯ãã¦ã»ãããã®ã§ãã
ãã®ã³ã¼ã¹ã§ã¯æ¬¡ã®ãããªãã¼ã«ãå
¥ãã¦ãã¢ããªã±ã¼ã·ã§ã³ãå®ãããã®ä»çµã¿ã¥ããã«ã¤ãã¦å¦ã³ã¾ãã
- eslint ã®è¨å®
- prettier ã®è¨å®
- TypeScript ã®å°å ¥
- husky + lint-staged ã«ãã£ã¦ git commit ã®åã«ãªã³ã¿ã¼ãèµ°ããã
- npm-run-all ã«ãã npm script ã®ä¸¦åå®è¡
åã¯éçåä»ãè¨èªã好ããªã®ã§èªåã触ãã³ã¼ãã«ã¯ TypeScript ãå
¥ãã¦ããããã¨æã£ã¦ãã¾ãã
husky 㨠lint-staged ã«ã¤ãã¦ã¯é¦´æã¿ããªãã£ãã®ã§ããããã£ããã¨ãã§ãããã ãªã¨åå¼·ã«ãªãã¾ããã
JavaScript Mocking Fundamentals
ãã¹ãã®ç²åº¦ã«ãã£ã¦ã¢ãã¯ã¯ã©ããã¦ãå¿
è¦ã«ãªã£ã¦ãã¾ãããã
éä¿¡å¦çã®ããã«æåããã失æãããããããªããã®ã¯ãã¹ãä¸ã«ä½¿ãããããã¾ããã
ãã£ã¨ jest.mock ãªã©ã使ã£ã¦æåããè¿ããªãããã«ã¢ãã¯ãããã¨ã§ãããã
ãã®ã³ã¼ã¹ã§ã¯ jest ãæä¾ãã¦ãã fn, spyOn, mock ãªã©ã®ä½¿ãæãå¦ãã ãããããã®ä»çµã¿ãç¥ãããã«ã¢ãã¯æ©è½ãèªä½ãã¾ãã
ã¬ãã¹ã³å ã® require ãªãã¸ã§ã¯ãã使ã£ã¦ã¢ãã¯æ©è½ãå®è£ ãã¦ããå ´é¢ã§ã¯ããããã£ã使ãæ¹ãããã®ãï¼ã¨ã¯ã¯ã¯ã¯ãã¦ãã¾ããã
Configure Jest for Testing JavaScript Applications
jest ã¯ã·ã³ãã«ã§ãã便å©ãªãã¹ããã¬ã¼ã ã¯ã¼ã¯ã§ãããããã³ãã¨ã³ãã®ã¢ããªã±ã¼ã·ã§ã³ããã¹ãããã¨ãã«ã¯ããã¤ãè¨å®ãå¿
è¦ã«ãªãã¾ããï¼ä¾:window ãªãã¸ã§ã¯ããåç
§ã§ããªãï¼
ãããã£ãã¤ã¾ãããã¤ã³ãã¸ã®å¯¾å¦æ³ã®ã»ãã«ã次ã®ãããªãã®ãå¦ã¹ã¾ãã
- ã³ã¼ãã«ãã¬ãã¸
- ããã¸ã§ã¯ãæ©è½
- ã¿ã¹ã¯ã©ã³ãã¼ã¨ãã¦ã®ä½¿ãæ¹
- ã¦ã©ããã¢ã¼ãããã便å©ã«ãããã©ã°ã¤ã³
jest ã®è¨å®ã«é¢ããæ
å ±ãããã¾ã§ã¾ã¨ã¾ã£ã¦ãããã¨ã¯ãã¾ããªãã®ã§ãã¨ã¦ãå¦ã³ã®ããå
容ã¨ãªãã¾ããã
å人çã«ã¯ããªããªã¹ã¹ã¡ã®ã³ã¼ã¹ã¨ãªã£ã¦ãã¾ãï¼
Test React Components with Jest and React Testing Library
Kent ãè¨ãã«ã¯ãä¿¡é ¼æ§ã®ãã UI ãã¹ãã¨ã¯ãã¦ã¼ã¶ã¼ãå®éã« UI ã使ãã¨ãã®æ§åããªã¢ã«ã«åç¾ã§ãã¦ãããã®ãã ããã§ãã
ããã§ã¯ãã®ä¿¡é ¼æ§ã®ãããã¹ããæ¸ãããã«æ¬¡ã®ãããªãã¨ãå¦ãã§ããã¾ãã
- Testing Library ã®ä½¿ããã
- ãªãã¡ã¯ã¿ãªã³ã°ãããããã¹ããæ¸ãããã®èãæ¹
- TDD ã«ããã³ã³ãã¼ãã³ãã®å®è£ æ¹æ³
- Context API ã使ã£ãã³ã³ãã¼ãã³ãã®ãã¹ãï¼react-touter, Reduxï¼
- ã«ã¹ã¿ã Hooks ã®ãã¹ãæ¹æ³
- ã¢ããªã±ã¼ã·ã§ã³å ¨ä½ã®ã¤ã³ãã°ã¬ã¼ã·ã§ã³ãã¹ã
- éåæå¦çã®ã¢ãã¯
åé ã§ãå°ãæ¸ãã¾ãããããã¨ãã¨å㯠UI ãã¹ãã«é¦´æã¿ããªã価å¤ã®ãã UI ãã¹ããã©ãæ¸ãããããã®ã ããã¨æ©ãã§ãã¾ããã
Testing JavaScript ãå§ããã®ããã®ã³ã¼ã¹ã§ãã®çãããããã®ã§ã¯ãªããã¨æã£ãã®ããã£ããã§ãã
çµæã¨ãã¦æå¾
ãã¦ãã以ä¸ã®ãã®ãå¦ã¶ãã¨ãã§ãã¾ããï¼
ã³ã¼ã¹å
ã§ãã¹ããã¢ããªã±ã¼ã·ã§ã³ãå£ããã«ãªãã¡ã¯ã¿ãªã³ã°ãã¦ããæ§åãè¦ãã¦ããã¾ããï¼
ããã«ã¯ãã³ãããªã¼ã
Install, Configure, and Script Cypress for JavaScript Web Applications
ãã®ã³ã¼ã¹ã§ã¯ E2E ãã¹ãã®ãã¬ã¼ã ã¯ã¼ã¯ã§ãã Cypress ã®ä½¿ãæ¹ã«ã¤ãã¦å¦ã³ã¾ãã
主ãªå
容ã¯æ¬¡ã®ã¨ããã§ãã
- Cypress ã®ã¤ã³ã¹ãã¼ã«ããè¨å®
- Cypress Testing Library ã®ç´¹ä»
- ã«ã¹ã¿ã Cypress Command ã®ä½ãæ¹
- ãããã°æ¹æ³
ãã¡ããããã¾ã¨ã¾ã£ãå
容ã«ãªã£ã¦ãã¾ãã
ãCypress ããã¹ããã¦ãããã¦ã¼ã¶ã¼ã ã¨èãã¦ãã¹ãã³ã¼ããæ¸ãã®ã好ã¿ã§ããã¨ããé¨åãå°è±¡çã§ããã
describe('anonymous calculator', () => { it('can make calculations', () => { const user = cy user.visit('http://localhost:8080') .get('xxx') .click() ... .get('yyy') .should('have.text', '1') }) })
Use DOM Testing Library to test any JS framework
React, Vue, Anguler, jQuery, ...etc 㧠DOM Testing Library ã使ã£ã¦ãã¹ãããã¨ãã®è©±ãæ¸ããã¦ãã¾ãã
React Testing Library ã®ããã«ããããã®ãã¬ã¼ã ã¯ã¼ã¯ã«ç¹åãã Testing Library ãããä¸ãæ¢ãã¦å°ãä½ã¬ãã«ãªã©ã¤ãã©ãªã¨ãã¦ä½ç½®ãã DOM Testing Library ã使ã£ãã³ã¼ããç´¹ä»ãã¦ãã¾ãã
ãããããã®ã¯ render é¢æ°ãèªä½ããå¾ã®ãã¹ãã³ã¼ããã©ã®ãã¬ã¼ã ã¯ã¼ã¯ã§ãã»ã¨ãã©å¤ãããªãã¨ããã§ãã
ãã㯠Testing Library ãå®è£
ã®è©³ç´°ãé ãããã¹ããæ¸ãããã® API ãæãã¦ãã証æ ã§ãã
ãããªãä½ãã®ãã¬ã¼ã ã¯ã¼ã¯ã§å¦ãã ãã¹ãã®ç¥èãä»ã®ãã¬ã¼ã ã¯ã¼ã¯ã§ã使ããã ãããªã¨æãã¾ããã
Test Node.js Backends
Express ã使ã£ãã¢ããªã±ã¼ã·ã§ã³ãä¾ã¨ãã¦ä½¿ããNode.js ã® Web ãã¬ã¼ã ã¯ã¼ã¯å ¨è¬ã§æ±ãããããªç¥èãå¦ã¹ã¾ãã
- ç´ç²ãªé¢æ°ã®ãã¹ã
- ããã«ã¦ã§ã¢ã®ãã¹ã
- ã³ã³ããã¼ã©ã¼ã®ãã¹ã
- API route ã®ãã¹ã
- ãµã¼ããã¼ãã£ã®ä¾åé¢ä¿ãã¢ãã¯ãã
- èªè¨¼æ¸ã¿ã³ã¼ãã®ãã¹ã
å®ã¯ã¾ã ãã®ã³ã¼ã¹ã«ã¤ãã¦ã¯å¦ã¹ã¦ããªãã®ã§è©³ããå
容ãæ¸ãã¾ããã
ããã¯ã¨ã³ãã§å¿
è¦ã¨ãªãæ®éçãªãã¹ãã®ç¥èãå¦ã¹ãããªé°å²æ°ã¯ããã¾ããã
ã¬ãã¹ã³æ°ã¯ Test React Components with Jest and React Testing Library ã¨åããããããã®ã§ãåã®å
¥ãããã伺ãã¾ãã
ãããã«
ãããã ã£ãã§ããããããããã§ã Testing JavaScript ã«èå³ãæã£ã¦ããã ããã幸ãã§ãã
å人çã«ã¨ãã«å¦ã³ããã£ã¦ããã£ããªã¨æããã®ã¯æ¬¡ã® 2 ã¤ã§ããã
- Configure Jest for Testing JavaScript Applications
- Test React Components with Jest and React Testing Library
ã¡ãªã¿ã«ä»åç´¹ä»ãããã¹ã¦ã®ã³ã¼ã¹ãåè¬ããã«ã¯ $332 ãããã¾ãï¼ï¼ä¸é¨ã®ã³ã¼ã¹ã ããå¦ã¹ãå®ãã³ã¼ã¹ãããã¾ãï¼
ä¸ç¬é«ãæããããç¥ãã¾ãããå¤æ®µã«ååè¦åã£ã価å¤ããã£ãã¨æãã¦ãã¾ãã
åèã¨å¼ã°ãã¦ãããããªãé«ãã®æè¡æ¸ 5, 6 ååã ã¨èããã°å®ãå®ãã
ã¿ãªããã Testing JavaScript ã§ä¿¡é ¼ã§ãããã¹ãã®æ¸ãæ¹ãå
±ã«å¦ãã§ããã¾ãããï¼
ããã§ã¯ãã¾ãã