0.1.2 • Published 2 years ago

cypress-ws-intercept v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Cypress WebSocket intercept

Usage:

cy.interceptWs('/ws', (income, outcome) => {
    if (income) {
        // TODO
    }

    if (outcome) {
        // TODO
    }

    return {income: income, outcome: outcome}
});

Configure:

// cypress.json
{
  "env": {
    "cypressWsProxy": {
      "serverPort": "4321",
      "targetUrl": "wss://gas-price-api-staging.1inch.io/ws"
    }
  }
}

Install:

Install package:

# for npm
npm install cypress-ws-intercept
# for yarn
yarn add cypress-ws-intercept

required: load this module from the support file

// cypress/support/commands.js
import 'cypress-ws-intercept/dist/commands';

required: load this module from the plugin file

// cypress/plugins/index.js
module.exports = (on, config) => {
    require('cypress-ws-intercept/dist/plugin')(on, config);
    // make sure to return the config object
    // as it might have been modified by the plugin
    return config
}

optional: add TypeScript types

{
  "compilerOptions": {
    "types": ["cypress", "cypress-ws-intercept"]
  }
}