Testing the new feature

Running the tests is a great way to minimize the number of bugs introduced in the application along with the new feature. Let's go ahead and test the implementation of the administrator page.

AngularJS testing

Like all other tests, we are testing our Angular controllers with the Mocha and Karma runners. Since we modified admin.controller.js, we need to test that all is working as intended. Add this new file:

/* client/app/admin/admin.controller.spec.js */ describe('AdminCtrl', function() { beforeEach(module('meanshopApp')); var Product, User, $state, $controller, controller, $scope; var productAttributes = [ {_id: 1, title: 'Product1', price: 100.10, stock: 10}, {_id: 2, title: 'Product2', price: 200.00, stock: 20} ]; var ...

Get Web Application Development with MEAN 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.