Tag Archives: nodejs

Testing Mean.js Controllers – Part 2

You need to test that only authorized users can perform certain functions, to help prevent AshleyMadison-like embarrassments. Plus, doing so will boost your code coverage metrics by hitting all of those auth failure branches. For mean.js with passport, you normally … Continue reading

Posted in Software | Tagged , | Leave a comment

Testing Mean.js Controllers – Part 1

It’s time to test controllers. In this post, I’ll test a controller that returns a json response. Step 1 is to install node-mocks-http. Step 2 is to download jsdValidator. In our sample controller test file, include jsdValidator and create a schema. … Continue reading

Posted in Software | Tagged , | Leave a comment

Using Codepainter to Format your Node.js App

I previously posted about using jshint to catch style errors in your code. To be sure, it’s way, way, way better to have a style formatter automatically apply your chosen style right within your editor–or at least flag your errors … Continue reading

Posted in Software | Tagged | Leave a comment

Complexity Analysis for Node.js Apps

In previous posts, I introduced style checking (linting) using jshint, integration testing using mocha and should, code test coverage using coverage, and vulnerability identification using retire. If you’re starting a new project, I strongly encourage you to integrate these packages … Continue reading

Posted in Software | Tagged | Leave a comment

Vulnerability Detection for Node.js Apps Using Retire

Eliminating from your application all code–include node modules–with known vulnerabilities is an essential part of secure coding. Retire is a node.js package that looks for reported vulnerabilities in your node modules and/or javascript code. It’s dirt simple to use–so there’s … Continue reading

Posted in Software | Tagged , | 1 Comment

Style Checking (linting) Node.js Apps

Style checking (aka linting) is a vital part of any application development process. Sloppy coding practices increase the chances of coding errors and other problems later on, and style checking can help flag many coding problems to keep your code … Continue reading

Posted in Software | Tagged , | Leave a comment

Node.js Tests using Mocha

In this post, I want to talk a little more about basic Mocha tests. Here are two tests in my mail.service.test file: var mail = require(‘app/services/mail.service’); var config = require(‘../../config/config’); var should = require(‘should’); describe(‘Send Mail’, function() { it(‘should send … Continue reading

Posted in Software, Uncategorized | Tagged , , , | Leave a comment