Unit testing ValidationError

Next, let's focus on testing the ValidationError class. Once again, we will move the validation.js file into its own director:

$ cd src/validators/errors/ && \  mkdir validation-error && \  mv validation-error.js validation-error/index.js && \  cd ../../../

Now, create a new file at src/validators/errors/validation-error/index.unit.test.js to house our unit tests:

import assert from 'assert';import ValidationError from '.';describe('ValidationError', function () {  it('should be a subclass of Error', function () {    const validationError = new ValidationError();    assert.equal(validationError instanceof Error, true);  });  describe('constructor', function () { it('should make the constructor parameter accessible via the ...

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.