Javascript — How to set up a testing environment with Jasmine and karma

From testing a single javascript file to testing Angular project

Bhargav Bachina
Bachina Labs

--

Javascript is one of the popular programming languages nowadays. We are shipping thousands of lines of code to production every day and shipping with confidence is very important for both businesses and developers. It is very difficult to predict the application behavior in production and a small bug in the production environments leads to unexpected behavior and non-availability of apps.

Jasmine is an excellent framework for testing javascript apps and it provides a lot of good features to test applications in both browser and server side. Jasmine is a behavior-driven javascript framework and combines with karma, a test runner becomes a powerful testing setup for our javascript apps.

Testing with jasmine and karma

Here are the topics that we cover in this article

  • Testing with jasmine in the browser
  • Testing with jasmine on the server (node)
  • Setup and teardown methods
  • focused, pending and skip tests
  • Using this keyword
  • Integration with karma (javascript)
  • Integration with karma (typescript)

--

--