Code Monkey home page Code Monkey logo

cypress-example-recipes's Introduction

Recipes Circle CI Travis CI

This repo contains various recipes for testing common scenarios using Cypress.

Contents

Overview

  • This is still a WIP, and we'll be adding recipes often.
  • All of the tests are found in the cypress/integration folder.
  • We boot a separate node server per recipe.
  • Each example has all of its own backend and frontend assets.

Installation

## install all dependencies
npm install

## boot the various node servers
## to use in the tests
npm start

## or if you want to make modifications
## to the node server code and have
## the servers automatically restart
npm run dev

Recipes

This recipe shows you how to:

  • Import ES2015 modules
  • Require CommonJS modules
  • Organize reusable utility functions
  • Import 3rd party node_modules

This recipe shows you how to:

  • Unit test your own application code libraries
  • Import modules using ES2015
  • Test simple math functions
  • Test the canonical fizzbuzz test

This recipe shows you how to:

  • Unit test a React JSX Component using Enzyme
  • Import enzyme from node_modules
  • Extend chai assertions with chai-enzyme

This recipe shows you how to:

  • Use cy.stub to stub dependencies in a unit test
  • Handle promises returned by stubbed functions
  • Handle callbacks in stubbed functions

This recipe shows you how to:

  • Test a standard username/password HTML form
  • Test errors submitting invalid data
  • Test unauthenticated redirects
  • Authenticate users with cookies
  • Create a custom login test command
  • Bypass needing to use your actual UI
  • Increase speed of testing with cy.request

This recipe shows you how to:

  • Test an AJAX backed username/password form
  • Test errors submitting invalid data
  • Stub JSON based XHR requests
  • Stub application functions
  • Create a custom login test command
  • Bypass needing to use your actual UI
  • Increase speed of testing with cy.request

This recipe shows you how to:

  • Use cy.request to get around CSRF protections
  • Parse CSRF tokens out of HTML
  • Parse CSRF tokens out of response headers
  • Expose CSRF via a route
  • Disable CSRF when not in production

This recipe shows you how to:

  • Login when authentication is done on a 3rd party server
  • Parse tokens using cy.request
  • Manually set tokens on local storage
  • Map external hosts and point to local servers

This recipe shows you how to:


This recipe shows you how to:

  • Test anchor links opening in new tabs: <a target="_blank">
  • Test anchor links that link to external domains: <a href="...">
  • Prevent content from opening in a new tab
  • Request external content that would open in a new tab
  • Speed up tests by reducing loading times

This recipe shows you how to:

  • Interact with elements which are hidden by CSS
  • Trigger mouseover, mouseout, mouseenter, mouseleave events
  • Get around the lack of a cy.hover command

This recipe shows you how to:

  • Use cy.visit onBeforeLoad callback
  • Start your application with test data
  • Stub an XHR to seed with test data
  • Wait on an XHR to finish

This recipe shows you how to:

  • Use cy.spy to verify the behavior of a function
  • Use cy.stub to verify and control the behavior of a function
  • Use cy.clock and cy.tick to control time
  • Stub window.fetch to control server responses

cypress-example-recipes's People

Contributors

brian-mann avatar chrisbreiding avatar jennifer-shehane avatar

Watchers

James Cloos avatar Michael avatar

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.