From the course: Vue.js: Testing and Debugging

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Testing asynchronous code

Testing asynchronous code

- [Instructor] Asynchronous code is very common in front end applications. This makes it very important to learn how to test the parts of your code base that you want asynchronously. For this purpose, a new function, async print, have been added to the utilities model. This function mocks an asynchronous process by printing out the hello world string two seconds after it is invoked. The async function without a promise that resolves a string. Let's go ahead and test this function's behavior. To follow along with this video, you need the 02_06b branch of the project. So make sure you are on the 02_06b branch. Go into the test folder and create a new file with the name async.js. Inside the test file, import the async print function. Next, we'll be writing a test case that checks that the asynchronous function prints the string hello world as expected. Inside a test case scaffold, we call the asynchronous function and use…

Contents