[Jest] Testing Asynchronous Code

0. 참고자료 Testing Asynchronous Code · Jest It’s common in JavaScript for code to run asynchronously. When you have code that runs asynchronously, Jest needs to know when the code it is testing has completed, before it can move on to another test. Jest has several ways to handle this. 1. 비동기 코드 테스트 javascript를 … 더 읽기

[Javascript] async & await

0. 참고자료 1. async async function – JavaScript | MDNMDN async function 선언은 AsyncFunction객체를 반환하는 하나의 비동기 함수를 정의합니다. 비동기 함수는 이벤트 루프를 통해 비동기적으로 작동하는 함수로, 암시적으로 Promise를 사용하여 결과를 반환합니다. (출력값이 Promise 객체다.) 그러나 비동기 함수를 사용하는 코드의 구문과 구조는, 표준 동기 함수를 사용하는 것과 많이 비슷합니다. (특장점!) 비동기 함수를 사용하는 그 어떤 … 더 읽기

[Javascript] Promise

1. Promise Jest를 공부하면서 비동기 처리와 관련한 내용이 나왔다. 비동기 처리를 편하게 도와주는 Promise 객체에 대해서 배웠고 활용해 보았다. Promise를 활용하는 것에 있어서 중요한 포인트는 2가지다. Promise 객체는 선언과 동시에 작업을 처리하니깐 선언되는 위치를 조심해야 한다. 작업을 수행할 것이 확정되는 순간 선언하도록 하자. 아래는 구체적으로 promise를 활용하는 사례다.