Writing Asynchronous Tests
Learn to write and test asynchronous code in this lesson.
We'll cover the following...
Testing an asynchronous function
We are going to write unit tests on the getName
function below:
export async function getName(id) {
await wait(200);
return names.length <= id ? null : names[id];
}
The getName
function is asynchronous and returns a promise of either a name or null
. It is asynchronous because of the call to a wait
function, which uses setTimeout
to resolve a ...
Access this course and 1400+ top-rated courses and projects.