September 2018
Intermediate to advanced
764 pages
20h 6m
English
When we installed the mocha npm package, it provided us with the mocha command to execute our tests. When we run mocha, it will inject several functions, including describe and it, as global variables into the test environment. The describe function allows us to group relevant test cases together, and the it function defines the actual test case.
Inside index.unit.tests.js, let's define our first describe block:
import assert from 'assert';import generateValidationErrorMessage from '.';describe('generateValidationErrorMessage', function () { it('should return the correct string when error.keyword is "required"', function () { const errors = [{ keyword: 'required', dataPath: '.test.path', params: { missingProperty: ...Read now
Unlock full access