The Node.js Way
352 views | +0 today
Follow
Your new post is loading...
Your new post is loading...
Rescooped by Arska from JavaScript for Line of Business Applications
Scoop.it!

Unit testing Sails JS: How to mock SailsJS Services in Controllers

Unit testing Sails JS: How to mock SailsJS Services in Controllers | The Node.js Way | Scoop.it

Let's suppose you wrote a SailsJS Controller and a SailsJS Service. You got them to work together, and now you want to mock the service while testing your controller.

The problem is that SailsJS magically injects Services -- and Models, and everything else -- into the Controller, making it difficult to simply call HelloController.index() without lifting SailsJS. We need the dependencies to be in place (otherwise we will get a bunch of ugly undefined is not a function kind of errors.

Fortunately, lifting SailsJS in code is almost as easy as running sails lift on your command line, and that is exactly what we are going to do in order run our tests.


Via Jan Hesse
more...
No comment yet.
Rescooped by Arska from Nodejs-code
Scoop.it!

The five minute beginner’s guide to installing and testing Redis and Node.js on OS X

Redis is an open source, advanced key-value store. Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model..


Via nodejs-code
more...
No comment yet.
Rescooped by Arska from JavaScript for Line of Business Applications
Scoop.it!

wolfpack - SailsJS Model Testing Library

wolfpack - SailsJS Model Testing Library | The Node.js Way | Scoop.it

Wolfpack helps you test your SailsJS models without the need for a db or lifting your sails app.

Basically, this is a library that instantiates your Sails models so that you can use them in your tests, without worrying about setting up a db, which introduces latency to your tests. By defaults it spies all Model functions with sinonJS, so you can test if the correct parameters are being sent to the model.


Via Jan Hesse
more...
No comment yet.