Fireship · @fireship

Cypress End-to-End Testing

Uploaded June 22, 2018 · Length 9:34

Cypress End-to-End Testing

Summary

Learn how to use Cypress for end-to-end testing of web applications, including setting up Cypress, writing tests, and debugging with time travel capabilities.

  • cypress end-to-end testing
  • web application testing
  • testing with cypress
  • time travel debugging
  • cypress tutorial

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    [Music]

  2. 0:06

    Cyprus is an end end testing library

  3. 0:09

    that will change your life as a

  4. 0:10

    developer I say that because it allows

  5. 0:11

    you to speed up the testing process of

  6. 0:14

    the user experience and it will help you

  7. 0:15

    catch bugs that you didn't even know

  8. 0:17

    existed it's super easy to set up and

  9. 0:19

    the learning curve is very minimal so if

  10. 0:21

    you have an existing app I recommend

  11. 0:22

    that you follow along with this episode

  12. 0:23

    in your own project to see what I mean

  13. 0:25

    first hand if you're new to the channel

  14. 0:27

    make sure to LIKE and subscribe and you

  15. 0:29

    can find the source code at angular

  16. 0:30

    firebase com in case you're not familiar

  17. 0:33

    and testing is the process of loading up

  18. 0:35

    your web application in the browser and

  19. 0:37

    testing things as if it was a real user

  20. 0:40

    performing these actions such as

  21. 0:41

    clicking buttons filling out forms and

  22. 0:43

    things like that

  23. 0:44

    so if you're an angular developer you

  24. 0:45

    might already know that angular ships

  25. 0:47

    with its own and and testing library

  26. 0:49

    called protractor so why do we need

  27. 0:51

    Cypress the short answer is that Cypress

  28. 0:53

    just provides a better developer

  29. 0:54

    experience but the longer answer is that

  30. 0:57

    protractor was originally developed for

  31. 0:58

    angularjs and it just hasn't evolved the

  32. 1:01

    way Cypress has first of all Cypress

  33. 1:03

    provides a really nice DSL for writing

  34. 1:05

    expressive and and tests which we'll see

  35. 1:07

    in the code here coming up then it

  36. 1:09

    provides this really nice test Runner

  37. 1:10

    which is an electron app that will run

  38. 1:12

    your app in the browser

  39. 1:13

    and then give you time travel debugging

  40. 1:15

    capabilities for each spec so for every

  41. 1:17

    action that takes place in the app it

  42. 1:19

    will save a snapshot of the state as

  43. 1:21

    well as an image of the UI so you know

  44. 1:22

    how things change before and after some

  45. 1:24

    action took place and in my experience

  46. 1:26

    writing a really good test suite is much

  47. 1:28

    more effective at preventing bugs than

  48. 1:30

    using a state management library like

  49. 1:31

    redux or something along those lines for

  50. 1:33

    this project I'm going to be starting

  51. 1:35

    from the firestarter demo app which

  52. 1:37

    already has user authentication and a

  53. 1:39

    buyer store database feature implemented

  54. 1:40

    in it over the next few minutes we'll

  55. 1:42

    test that the user can sign up log out

  56. 1:45

    log back in create some items in the

  57. 1:47

    database and do a few other things in

  58. 1:49

    between the first thing we need to do is

  59. 1:51

    install it with NPM install Cypress save

  60. 1:53

    dev then I'm also installing a library

  61. 1:55

    called chance which we'll use to

  62. 1:56

    generate random fixtures for our specs I

  63. 1:59

    have completely removed protractor from