Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Unit Testing in Angular

Unit Testing in Angular

Ciro Nunes

April 13, 2016
Tweet

More Decks by Ciro Nunes

Other Decks in Programming

Transcript

  1. 1. Unit testing 101 2. Setup Angular testing environment 3.

    Test Angular services and components AGENDA
  2. ├──.angularOcliObuild.js. ├──.angularOcli.json. ├──.config. ├──.e2e. ├──.karmaOtestOshim.js. ├──.karma.conf.js. ├──.package.json. ├──.protractor.conf.js. ├──.public. ├──.src.

    ├──.tslint.json. ├──.typings. └──.typings.json └──.client. ....├──.app. ....│...├──.routeOconfig.ts. ....│...├──.testOproject.html. ....│...├──.testOproject.spec.ts. ....│...└──.testOproject.ts. ....├──.app.ts. ....├──.favicon.ico. ....├──.index.html. ....├──.tsconfig.json. ....└──.typings.d.ts
  3. 1. Unit tests helps us to test applications automatically 2.

    Good tests are small and test the public interface SUMMARY
  4. 1. Unit tests helps us to test applications automatically 2.

    Good tests are small and test the public interface 3. The CLI is the recommended way to get up and running SUMMARY
  5. 1. Unit tests helps us to test applications automatically 2.

    Good tests are small and test the public interface 3. The CLI is the recommended way to get up and running SUMMARY 4. The testing library wraps Jasmine and provide convenient features
  6. 1. Unit tests helps us to test applications automatically 2.

    Good tests are small and test the public interface 3. The CLI is the recommended way to get up and running SUMMARY 4. The testing library wraps Jasmine and provide convenient features 5. beforeEachProviders + inject/injectAsync to use the DI system
  7. 1. Unit tests helps us to test applications automatically 2.

    Good tests are small and test the public interface 3. The CLI is the recommended way to get up and running SUMMARY 4. The testing library wraps Jasmine and provide convenient features 5. beforeEachProviders + inject/injectAsync to use the DI system 6. provide to mock dependencies
  8. 7. TestComponentBuilder returns the ComponentFixture instance 8. The ComponentFixture contains

    the component instance 9. The ComponentFixture contains the DOM element SUMMARY
  9. 7. TestComponentBuilder returns the ComponentFixture instance 8. The ComponentFixture contains

    the component instance 9. The ComponentFixture contains the DOM element SUMMARY 10. fakeAsync and tick to test async code in a sync fashion
  10. 7. TestComponentBuilder returns the ComponentFixture instance 8. The ComponentFixture contains

    the component instance 9. The ComponentFixture contains the DOM element SUMMARY 10. fakeAsync and tick to test async code in a sync fashion 11. injectAsync will be deprecated in favor of async