What does a server do?

Node js and Angular js - Testing server side and client side code - What is your ("the best") approach?

  • We are currently playing around with Node.js and Express.js on the server side and Angular.js on the client side. We like it so we wanted to implement a small project with this technology stack. Right now we want to set up a nice test suite. Because I liked the Angular.js tutorial I took the test suite from there for the client. So I use the testrunner karma. Then I tried to run the server side code also with karma but I didn't figured out how to do this. This was the reason why I run jasmine-node for the server side code. Now I ended up using grunt.js. Grunt first invokes the server tests with jasmine-node and after that the karma test runner (with the Angular.js test suite from the Angular.js tutorial) This isn't quite the result I wanted. One argument for looking into Node.js was, the same language on the server and client. So I was hoping to have one test suite for the whole application. Because the next problem comes with code coverage. I want one coverage report for all my js files and not 2. One for server side code and one for client side code. I am wondering if I have wrong assumptions or if there is a way to unify the test process. How do you test your code (client&server). What is a good approach? Are there somewhere good tutorials or starting points on this issue? Thank you for every tip and clarification. Bye, Tschoartschi

  • Answer:

    For unit tests, it does not make sense to use Karma to test your server side code. The point of Karma is to make it easy to run tests and run them across multiple real browsers easily. Running server-side code inside of a browser doesn't really make sense. I'd recommend using one of the grunt plugins for Karma, alongside a grunt plugin for testing your server-side code. Then you can have one command that tests both.

Brian Ford at Quora Visit the source

Was this solution helpful to you?

Other answers

For server side (Node.js) unit testing, i would like to suggest you to use mocha. Now the next question will arise in your mind how to use mocha in your project, so i will suggest you to go through the given Cronj github link:- https://github.com/Cron-J/CSV-Generator For front end side (Angular.js) unit testing, i would like to suggest you to use protractor. Above given link will explain about inital setup and you will get mocha and protractor test cases.

Soni Pandey

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.