Angular testing

1,076 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
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,076
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

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!

×