Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Angular testing

1,194 views

Published on

Angular Unit Testing, Mid Way Testing and E2E Testing workshop by Mathieu Chauvinc, CTO of Red Ape Solutions Malaysia

Published in: Education, Technology
  • Be the first to comment

  • Be the first to like this

Angular testing

  1. 1. Angular Testing with Mathieu Chauvinc, Managing Director, Red Ape Solutions
  2. 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. 3. 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
  4. 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. 5. 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
  6. 6. Unit testing – More functionalities ● Karma coverage – Install karma-coverage (reporter) – Configuration ● PhantomJS ● Reporters
  7. 7. 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
  8. 8. E2E testing ● Application level ● Access to HTML ● No access to internals ● Protractor – Selenium – Chrome Web driver – Configuration – Params Check out E2E
  9. 9. 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
  10. 10. E2E testing ● Information about element – – GetLocation, getSize – GetCssValue, GetAttribute – ● GetText, getInnerHtml IsEnable, isSelected, isDisplayed, isElementPresent Actions – sendKeys – Click – Clear – submit
  11. 11. Thank you!

×