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

Create your Angular App and test it with Jest a...

Create your Angular App and test it with Jest and Cypress

Sometimes it's difficult to find a great combination of packages to start a new app. Initialization and configuration can be a pain if we don't know a set of tools that makes our life easier. In this workshop we will show you how to create a small Angular app that is tested with Jest and Cypress, to set a good point of start for your future applications.

Objectives of this workshop:

Angular:

- Easy initialization of an Angular workspace with NX
- Create components & services with Angular CLI
- Perform an HTTP request with HTTPClient service
- Component communication via service

Unit testing with Jest:

- Unit testing components & services
- Mocking services
- Snapshot Testing

E2E with Cypress:

- Creation of E2E and integration tests for the app
- Mocking HTTP requests in Cypress

This is the repo used for our workshop:

https://github.com/malaga-front-end/nrwl-angular-jest-cypress-quickstart

Avatar for Miguel Angel Muñoz

Miguel Angel Muñoz

November 08, 2019
Tweet

Other Decks in Programming

Transcript

  1. 1 The Workshop | Public Create your Angular App with

    Unit tests and E2E Install them before workshop starts! Node.js https://nodejs.org/en/download/ Angular CLI npm install –g @angular/cli Nx npm install –g @nrwl/nx Init workspace npm init nx-workspace myapp Repo https://github.com/malaga-front-end/nrwl-angular- jest-cypress-quickstart
  2. 3 The Workshop | Public Miguel Ángel Muñoz Diego Romero

    Who are we? @ma_munoz_dev Miguel Ángel Muñoz Alonso mamunoz-dev Diego Romero Parrilla diegorp
  3. What you’ll learn Components with Angular CLI Services with Angular

    CLI Interaction between components 6 The Workshop | Public
  4. What you’ll learn The FE Test Pyramid What tests should

    I do? e2e snapshot unit tests 7 The Workshop | Public
  5. What you’ll learn Unit testing services Unit testing components Mocking

    services Snapshot testing 8 The Workshop | Public
  6. 13 The Workshop | Public What do we need from

    each one? • Initialise Angular Workspace • Jest • Cypress • Generate our components • Generate our services
  7. 14 The Workshop | Public Angular CLI Installing Angular CLI

    & Nx npm install –g @nrwl/nx npm install –g @angular/cli Nx
  8. 20 The Workshop | Public Front-end test pyramid https://www.freecodecamp.org/news/the-front-end-test-pyramid-rethink-your-testing-3b343c2bca51/ e2e

    snapsh ot unit tests Multiple for each component One or two per component One or two for component communication
  9. Unit & snapshot testing with Jest Check if these components

    and services work! 21 The Workshop | Public