From the course: JavaScript: Test-Driven Development (ES6)

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Creating a Mocha setup file

Creating a Mocha setup file - JavaScript Tutorial

From the course: JavaScript: Test-Driven Development (ES6)

Start my 1-month free trial

Creating a Mocha setup file

- [Instructor] There's one more thing we have to do before writing and running our first integration tests. Since some of our tests will involve communicating with a database and possibly some other IO operations, it's safe to assume that we'll be using async/await in our code. Now, you might assume that Mocha would work out of the box with the async/await syntax, but unfortunately it currently does not. If you try to test asyn/await code without this fix we're about to look at, you'll most likely get a weird error message when running your tests. In order to avoid this, we just have to install a package. So, open a terminal, and make sure you're inside your project directory, and then run NPM install--save-dev regenerator-runtime. And hit enter. Now, in theory all we really need to do is import this package at the top of our first test file that runs. And it'll make our async tests work. And that would work,…

Contents