Code Monkey home page Code Monkey logo

frontend-testing-on-steroids-v2's Introduction

Front-end Testing on Steroids (V2)

Build Status Build Status Renovate enabled Open Source Love

The first version of this talk was about the main reasons that make UI Testing hard, this second part is more about how to leverage Cypress to improve front-end development productivity.

Please note: this is the spoken version of my "Front-end productivity boost: Cypress as your main development browser" article.

Talk walkthrough

  • Replacing E2E tests with UI Integration tests
  • Controlling the clock to test long waitings in a while
  • Testing corner cases by simulating network requests failure
  • Leveraging Chrome and React DevTools in UI tests
  • Using Cypress as the main development browser

During the talk, some interesting Cypress' features will be shown:

  • The Cypress UI
  • The amazing Test Runner
  • Actions are asynchronous by default
  • Elements retrieval by contents
  • The test and app use the same console.log
  • Time-travelling the test steps and pausing the test

Take a look at the complete authentication.e2e.test test and the authentication.integration.test one. They contains everything shown in the talk and a lot of comments.


About this repository

  • I bootstrapped this project with create-react-app
  • it contains a super-simple authentication form
  • it contains a fake server with artificial delays to simulate E2E testing slowness
  • it runs the tests in Travis too to show a complete UI Testing project
  • all the code is well commented, with a lot of links to the slide explanations
  • I wrote the front-end app with a outside-in approach writing the acceptance test at the beginning. I have not tested it manually at all!

How to play with it

There are four main commands:

  • npm run start: starts the (super simple) front-end app and the (fake) back-end app
  • npm run cy:open: opens the Cypress UI
  • npm test: launches both the front-end and the back-end apps, and runs cypress in the non-visual mode. Remember killing the manually launched apps since it uses the same ports

How to read it

  • launch the front-end app and take a look at the src/App.js file
  • launch both the back-end app and Cypress
  • launch the authentication.integration.test.js in Cypress and watch it running
  • open the cypress/integration/authentication.integration.test.js and explore it
  • then, move to the cypress/integration/authentication.e2e.test.js
  • in the end: run the npm test command

UI Testing Best Practices book

Do not forge to add a star to my (work in progress) UI Testing Best Practices book on GitHub ๐Ÿ˜Š

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.