Angular Testing with Mathieu Chauvinc, Managing Director, Red Ape Solutions
Angular.js Testing - Overview ● Unit tests – ● Midway tests – ● Karma + ngMidwayTester End to end testing – ● Karma Protractor Git repo: https://github.com/matiboy/AngularTesting.git
Unit testing ● Code level ● Smallest unit possible ● Using Karma – Configuration ● Auto refresh ● Include modules – Jasmine – Karma start – Describe/it – xdescribe/xit – iit Check out Unit
Unit testing ● module( === angular.mock.module( ● $injector and _thingToInject_ ● beforeEach ● afterEach ● Assertion tools toBe, toBeDefined, toBeNull, toBeLesserThan, etc.... ● Create your own assertions (will do for E2E)
Unit testing ● Spies – Create spy – Call through – Access information about calls ● Spy object ● Dependency injection: override functionalities ● Working with promises: resolving (scope.$apply) ● $httpBackend (Watch out for angular mocks version) Check out Unit2
Unit testing – More functionalities ● Karma coverage – Install karma-coverage (reporter) – Configuration ● PhantomJS ● Reporters
Midway testing ● Allowed to cross boundaries ● Check – existence of modules – Existence of routes – Slightly higher level code ● Create new config file ● Install ngMidwayTester – npm – Add to config files Check out Midway
E2E testing ● Application level ● Access to HTML ● No access to internals ● Protractor – Selenium – Chrome Web driver – Configuration – Params Check out E2E
E2E testing ● Selectors – – By input – By css – By xpath – ● By binding Row / column Element queries – are promises (async and have .then) – Can be chained with actions – Expect can be wrapped around them
E2E testing ● Information about element – – GetLocation, getSize – GetCssValue, GetAttribute – ● GetText, getInnerHtml IsEnable, isSelected, isDisplayed, isElementPresent Actions – sendKeys – Click – Clear – submit
Thank you!

Angular testing

  • 1.
    Angular Testing with MathieuChauvinc, Managing Director, Red Ape Solutions
  • 2.
    Angular.js Testing -Overview ● Unit tests – ● Midway tests – ● Karma + ngMidwayTester End to end testing – ● Karma Protractor Git repo: https://github.com/matiboy/AngularTesting.git
  • 3.
    Unit testing ● Code level ● Smallestunit possible ● Using Karma – Configuration ● Auto refresh ● Include modules – Jasmine – Karma start – Describe/it – xdescribe/xit – iit Check out Unit
  • 4.
    Unit testing ● module( ===angular.mock.module( ● $injector and _thingToInject_ ● beforeEach ● afterEach ● Assertion tools toBe, toBeDefined, toBeNull, toBeLesserThan, etc.... ● Create your own assertions (will do for E2E)
  • 5.
    Unit testing ● Spies – Create spy – Callthrough – Access information about calls ● Spy object ● Dependency injection: override functionalities ● Working with promises: resolving (scope.$apply) ● $httpBackend (Watch out for angular mocks version) Check out Unit2
  • 6.
    Unit testing –More functionalities ● Karma coverage – Install karma-coverage (reporter) – Configuration ● PhantomJS ● Reporters
  • 7.
    Midway testing ● Allowed tocross boundaries ● Check – existence of modules – Existence of routes – Slightly higher level code ● Create new config file ● Install ngMidwayTester – npm – Add to config files Check out Midway
  • 8.
    E2E testing ● Application level ● Accessto HTML ● No access to internals ● Protractor – Selenium – Chrome Web driver – Configuration – Params Check out E2E
  • 9.
    E2E testing ● Selectors – – By input – Bycss – By xpath – ● By binding Row / column Element queries – are promises (async and have .then) – Can be chained with actions – Expect can be wrapped around them
  • 10.
    E2E testing ● Information aboutelement – – GetLocation, getSize – GetCssValue, GetAttribute – ● GetText, getInnerHtml IsEnable, isSelected, isDisplayed, isElementPresent Actions – sendKeys – Click – Clear – submit
  • 11.