Posts

Showing posts with the label testing

Jasmine/Karma- Writing Unit Test Cases for Angular

Image
What is Jasmine?   DOM-less simple JavaScript testing framework. Jasmine is a Behavior Driven Development testing framework for JavaScript. It does not rely on browsers, DOM, or any JavaScript framework. Thus, it's suited for websites, Node.js projects, or anywhere that JavaScript can run. What is Karma?   Spectacular Test Runner for JavaScript. Karma is not a testing framework, nor an assertion library. Karma just launches a HTTP server, and generates the test runner HTML file you probably already know from your favorite testing framework. So for testing purposes you can use pretty much anything you like In short, Jasmine: Javascript Testing Framework.   Can be used as TDD Karma: Browser testing. Used as a Rest Runner TESTING ANGULAR COMPONENTS Consider the below angular component: app.component.ts app.component.spec.ts TESTING SERVICES Angular services contain UI-independent reusable business logic of the application. myservice.service.ts The spec file of this...