Running our unit tests

To run our test, we'd normally just run npx mocha. However, when we try that here, we get a warning:

$ npx mochaWarning: Could not find any test files matching pattern: testNo test files found

This is because, by default, Mocha will try to find a directory named test at the root of the project and run the tests contained inside it. Since we placed our test code next to their corresponding module code, we must inform Mocha of the location of these test files. We can do this by passing a glob matching our test files as the second argument to mocha. Try running the following: 

$ npx mocha "src/**/*.test.js"src/validators/users/errors/index.unit.test.js:1(function (exports, require, module, __filename, __dirname) { import ...

Get Building Enterprise JavaScript Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.