Top "Jasmine" questions

Jasmine is a behavior-driven development (BDD) framework for testing JavaScript code.

Running a single test file

Is there a way to run ng test for a single file instead of for the entire test suite? Ideally, …

angular jasmine angular-cli karma-runner
How do I test an AngularJS service with Jasmine?

(There is a related question here: Jasmine test does not see AngularJS module) I just want to test a service …

angularjs jasmine
How to stub a method of jasmine mock object?

According to the Jasmine documentation, a mock can be created like this: jasmine.createSpyObj(someObject, ['method1', 'method2', ... ]); How …

javascript jasmine
Unit testing an observable in Angular 2

What is the correct way of unit testing a service returning an Observable result in Angular 2? Let's say we have …

unit-testing jasmine angular observable
Checking object equality in Jasmine

Jasmine has built-in matchers toBe and toEqual. If I have an object like this: function Money(amount, currency){ this.amount = …

javascript bdd jasmine object-comparison
Expected a spy, but got Function

I am trying to implement a test (1) for this module (2). My purpose is to check if the collection is fetched …

javascript backbone.js jasmine marionette
How do we clear spy programmatically in Jasmine?

How do we clear the spy in a jasmine test suite programmatically? Thanks. beforeEach(function() { spyOn($, "ajax").andCallFake(function(params){ }) }) …

javascript jasmine
How does one stub promise with sinon?

I have a data service with following function function getInsureds(searchCriteria) { var deferred = $q.defer(); insuredsSearch.get(searchCriteria, function (insureds) { …

javascript jasmine sinon
Unit Testing AngularJS directive with templateUrl

I have an AngularJS directive that has a templateUrl defined. I am trying to unit test it with Jasmine. My …

angularjs angularjs-directive jasmine
How to access and test an internal (non-exports) function in a node.js module?

I'm trying to figure out on how to test internal (i.e. not exported) functions in nodejs (preferably with mocha …

node.js unit-testing jasmine mocha