Skip to content

player-two/testing-standards

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Angular Unit Testing Standards

Abstract

Unit testing can be describe as:

For every automatic action that occurs on controller initialization, or any controller method invoked in scope, test the following:

  1. Given correct input, does it call the expected external methods/query the expected external resources.
  2. Given correct results from all external methods/resources, does it generate the expected response.

If required by design:

  1. Given incorrect input, does it refuse the input with useful errors.
  2. Given incorrect results from external methods/resources, does it generate useful errors.

It should be immediately obvious what a test is testing, and why. If it isn't obvious, comments explaining/justifying the test assertions should be added.

When unit testing, we want to test at the smallest level possible.

Libraries

Docs Help Keywords
ngMock ngMock.md module, inject, $controller, $httpBackend
Sinon sinon.md stub, spy, called
Chai chai.md expect, to, equal, be
Sinon-chai N/A to.have.been.called (allows better chaining)
Mocha mocha.md describe, it, before, beforeEach, after, afterEach
Karma N/A Simply runs the tests

What do I test?

Unit Testing Chart

Credit to Sandi Metz from her talk at RailsConf 2013.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published