Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cypress-protobuf

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cypress-protobuf

Encode a Cypress fixture with Protocol Buffers

  • 1.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Cypress Protocol Buffers

Encode a fixture with Protocol Buffers

Build Status Build Status Commitizen friendly Open Source Love

Cypress Protobuf

Use this plugin to encode a Cypress fixture with Protocol Buffers.

Installation

npm i -D cypress-protobuf
# or
yarn add -D cypress-protobuf

then open your cypress/plugins/index.js file and register a new task

module.exports = on => {
  on("task", {
    protobufEncode: require("cypress-protobuf"),
  });
};

How to use it

To encode with Protocol Buffers a fixture

cy.fixture("FIXTURE_NAME.json+")
  .then(json => {
    cy.task("protobufEncode", {
      fixtureBody: json, // the fixture body
      message: "MESSAGE_NAME", // the protobuf message to use
      protoFilePath: "./public/example.proto", // the path (starting from your project directory) to the .profo file
    })
  .then(encodedJson => {
    // 🎉 `encodedJson` contains the encoded fixture
    cy.route({
      headers: {
        "content-type": "application/octet-stream"
      },
      response: encodedJson,
      url: 'API_URL'
    }).as("FIXTURE_NAME");
  });
});

and in your test you will wait for the request as usual

cy.wait("@YOUR_FIXTURE_NAME");

Take a look at the example test source code.

Tips

  • the plugin saves the last protoFilePath so you can avoid to pass it every time. You can even set it at the beginning of your test suite
before(() => {
  cy.task("protobufEncode", {
    protoFilePath: "./public/escrow/ui.proto"
  });
});

Contributors

Thanks goes to these wonderful people (emoji key):

Stefano Magni
Stefano Magni

💻 ⚠️

This project follows the all-contributors specification. Contributions of any kind welcome!

Keywords

FAQs

Package last updated on 30 May 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc