Node.js Silence Middleware Output When Testing

So I wanted to have the console output of my tests clean and not polluted by node app middleware output, such as that output by request modules when performing http requests. I remember briefly touching on this subject before when Silencing Log Output when testing. This is what the output looks like when I run …

Mocha Test JSON Schema is Valid

OK so it’s important to test your JavaScript applications especially in full-stack JS. I’ve touched on this subject before when I wanted to test if JSON was returned in a valid format. So let’s take this a bit further and look at how you can use Mocha to test your JSON Schema is valid (how …

Mocha Test Silence Log Output

When testing my server I have log output which I don’t want to appear when I run my tests using Mocha. I want to Silence Log Output!!! Ofcourse a solution is suggested by TJ! Let’s take a look… OK, so include this in your server.js file. // api middleware if (process.env.NODE_ENV !== ‘test’) {   …

Nodejs Mocha Test for Valid JSON

Mocha This is how you can use the Node.js test suite Mocha to Test for Valid JSON. This could come in handy when testing if API’s are returning valid JSON – essential part of your web application integration testing. Note: I’ve taken this testing concept further and added tests for JSON Schema as well. See …