Adding test cases for the new validation function

The first thing to do would be to write some test cases for the brand new validation function we just created, which means we're going to make a new test file called validation.test.js.

Inside there, we're going to load in an expect making a variable called expect. We could also make it a constant. We're going to set that equal to require and we're going to require the expect library:

const expect = require('expect');

Next up, we're going to load in RealString, import isRealString, and we're going to add three test cases. The describe blocks should be something like isRealString, and the three test cases will be as follows:

  • The first one, should reject non-string values, in this case I want ...

Get Advanced Node.js Development 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.