Message generator and tests

In this section you are going to break out some functionality currently in server.js into a separate file, and we're also going to set up our test suite so that we can verify if those utility functions are working as expected.

For the moment, our goal is going to be to create a function that helps us generate the newMessage object. Instead of having to define the object every single time, we'll simply pass in two arguments to a function, the name and the text, and it'll generate the object so we don't have to do that work.

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.