Git Product home page Git Product logo

full-network-proxy's Introduction

This is a demo repo with Cypress Specs showing features of the new network layer stubbing.

See Cypress issue #687 and pull request #1931

Main idea

Allow tests to specify values or callback functions that modify request and response objects. For example to reject a response to GET /app.js with 500 code one could simply do

cy.route({
  url: "/app.js",
  status: 500
})
cy.visit("index.html")

Tests can have additional logic to inspect the request object (or maybe response as well?) using a callback function

const name = "/app.js"
cy.route({
  status: req => {
    if (req.url === name) {
      // if the callback returns a value
      // it will be the response status
      return 404
    }
    // otherwise let the request go through
  }
})

Notice that a callback function is allowed to use variables in its parent scope, like name here. Thus even as we "ship" callback functions from the browser into the proxy layer of Cypress, we need to handle this correctly.

Organization

This repo shows different types of tests as if a "normal" user would write them. Thus there are a few example pages the /pages folder. There are different spec files showing different working features

Running

While the new version of Cypress with full network stubbing is not released, it is in the branch full-network-stubbing-687. So to run this repository (assuming it was cloned into local folder /git/repo)

full-network-proxy's People

Contributors

bahmutov 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.