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 ๐Ÿ˜Š

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

Contributors

noriste avatar renovate-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

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

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update dependency @testing-library/cypress to v9
  • Update dependency cypress to v12
  • Update dependency react-scripts to v5
  • Update dependency start-server-and-test to v2
  • Update react monorepo to v18 (major) (react, react-dom)
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

npm
package.json
  • axios 0.21.0
  • cors 2.8.5
  • express 4.17.1
  • react 17.0.1
  • react-dom 17.0.1
  • react-scripts 4.0.0
  • @cypress/browserify-preprocessor 3.0.1
  • @testing-library/cypress 7.0.1
  • cypress 5.6.0
  • cypress-skip-and-only-ui 1.2.10
  • cypress-watch-and-reload 1.2.18
  • nodemon 2.0.6
  • start-server-and-test 1.11.5
travis
.travis.yml
  • node 10

  • Check this box to trigger a request for Renovate to run again on this repository

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.