Unit Testing RxJs Retries

In a previous article I showed how to add conditional retry logic to RxJs based http requests. In the following post I will show how to unit test the retry logic.

Unit Testing EventEmitter in Angular

In this short post I will show you how to unit test EventEmitters in Angular

Angular Unit Testing

The new component based architecture in Angular is great for unit testing, so in the following article I will demonstrate how to unit test Angular 2.0 code using Jasmine and TypeScript.

Comprehensive guide to Unit Testing in AngularJS

Angular allows you to build amazing user interfaces, but as complexity increases, unit testing becomes a very important part of your project. In this article I will provide a comprehensive guide for how to successfully write unit tests in AngularJS. The examples are created using Jasmine, but the concepts are not directly tied to a specific testing framework.

Unit Testable Code with MVVM

Mock Exceptions Using MOQ

Mock Exceptions Using MOQ

Avoid Duplicate Mocking Code in Unit Tests

Avoid Duplicate Mocking Code in Unit Tests

How to Mock HttpContext

How to Mock HttpContext

Define Different Return Values in MOQ

Define Different Return Values in MOQ

How to Change Default Return Values in MOQ

How to Change Default Return Values in MOQ

Angular integration tests

Most developers are already familiar with unit testing, but in this article I will describe a second category of automated tests – integration tests.

How to mock http calls in Angular

For better testability, and other important reasons, it's generally advisable to add some form of abstraction around your http access layer. However, Angular offers its own “hook” for mocking if your code under test has a direct dependency on the $http service. In this post I will show how to tap into Angular's httpBackend service to define mocked responses to http requests.

How to inject Angular dependencies in Jasmine unit tests

Angular dependency injection is very flexible and easy to work with, but how do you inject dependencies in Jasmine tests. In the following short post I will show two common approaches

How to mock providers in Angular

Providers in Angular serve as a way to create independent components that can be injected into other components. There are several different variations on providers; service, factory, value, constant and provider, but the idea is very similar between all of them. In this post I will demonstrate how to mock the different types through Angular dependency injection.

How to unit test Angular run blocks

Run blocks in Angular are commonly used to bootstrap the application and run initial setup functions. In some cases the logic might be complex enough to warrant unit tests, so in the following post, I will demonstrate how to capture run block(s) from a unit test.

How to simulate and test failing promises in Angular

Whenever you make an asynchronous remote call there is always the chance that the call will fail. In this post I will demonstrate how to simulate and test failing promises when using Angular and $q.

How to mock promise based service dependencies in Angular

In this article I will show how to unit test an angular service by mocking its external dependency. The service under test is trivial, but the key point is to demonstrate how to mock its asynchronous dependencies using Angular and Jasmine.

How to Mock with NSubstitute

There are several great mocking frameworks available for .Net, but <a href='http://nsubstitute.github.io/' target='_blank'>NSubstitute</a> stands out because of its simple and elegant syntax. Perhaps the biggest benefit is how easy it is to integrate mocked objects with the code under test. There is no need for framework specific bootstrapping, or extra properties to access the objects you are mocking.

How to Create Xpath Using Linq

As an alternative to my previous xpath library, XpathItUp, I've created a lambda based framework for generating xpath expressions. The goal is to improve and address some of the short comings of my previous library.