일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- 빌트인 객체
- 브라우저의 렌더링 과정
- 비전공이지만 개발자로 먹고삽니다
- 자바스크립트
- ES6함수 추가기능
- DOM
- const
- 디스트럭처링
- 이미지 갤러리 최적화
- 모던 자바스크립트 Deep Dive
- 원시값과객체의비교
- 전역변수의문제점
- 프로그래머스
- var 사용금지
- 올림픽 통계 서비스 최적화
- 타입변환과단축평가
- 기술컨퍼런스
- 인터넷 장비
- 프론트엔드 성능 최적화 가이드
- 딥다이브
- 네트워크 연결과 구성요소
- 이벤트
- 블로그 서비스 최적화
- 프로퍼티 어트리뷰트
- 제너레이터와 async/await
- Babel과 Webpack
- 자바스크립트 딥다이브
- Set과 Map
- Property Attribute
- 스코프
- Today
- Total
목록Online Lectures/JavaScript Unit Testing - The Practical (8)
JDevBlog
Accessing The DOM from Inside Tests DOM vs NodeJS Environment Accessing the DOM Specialized Libraries Should set testing environment in package.json or right in the single file as jsdom or happy-dom for emulation. Set up testing to access html page content rendered at document of virtual window. fs and path are still available because all the Node APIs available inside the test files. the Dom is..
Mocking Global Objects & Functions Mocking Frontend Features Examples Case1. fetch is a globally available function which is not imported. Thus, cannot use vi.mock to replace a module in this case. SubGlobal method allows us to replace globally available objects and functions with implementations. Then, Production codes are not effected! sendDataRequest function export async function sendDataReq..
Dealing with Side Effects Dealing with Side Effects & External Dependencies Understanding Spies & Mocks Examples Why need? In some cases, test interacts with upper system such as hard drive, database outside of program and code. Means that there could be side effects. e.g. important files or data could be deleted or edited accidentally. spy fn creates an empty function that keeps track of any fu..
More Key Testing Library APIs toBe() vs toEqual() Testing Asynchronous Code Using Setup & Cleanup Hooks toBe vs toEqual() Use "toEqual" method for deep-comparison on values not address of the object. In contrary, toBe method does shallow comparison. Testing Asynchronous Code test code here case1. callback use DoneCallback Vitest and Jest will pick up errors and consider the test to have failed a..
Combining Units Testing Units With Dependencies Balancing Unit & Integration Tests Why do? Accidentally, If an order of codes is wrong and input has wrong value, although all unit tests passed, the function including the unit functions doesn’t work as intended. Solution: Integration Test
What to & Not to Test What should & shouldn’t be tested Good tests are short & concise key points What should & shouldn’t be tested Only test your code don't test third-party code don’t test what you cannot change Example, fetch() API Don't test if it works as intended Don't test your server-side code implicitly via your client-side code Write separate tests for your backend code instead Do Test..
Understanding Unit Testing Fundamentals Creating Unit Tests AAA - Arrange, Act, Asset AAA - Arrange, Act, Assert A - Arrange, Define the testing environment & values A - Act, Run the actual code / function that should be tested A - Assert, Evaluate the produced value / result and compare it to the expected value / result Writing Good Tests Is An Iterative Process! Test examples(basic-testing-fro..