juspay/hyperswitch

[CYPRESS_FRAMEWORK] Pass custom-headers before making a request

Open

#5,912 opened on Sep 16, 2024

View on GitHub
 (5 comments) (0 reactions) (0 assignees)Rust (4,676 forks)batch import
E-mediumgood first issuehacktoberfesthelp wantedjavascript

Repository metrics

Stars
 (42,690 stars)
PR merge metrics
 (Avg merge 6d 22h) (213 merged PRs in 30d)

Description

Description:

Cypress is the testing framework that Hyperswitch is using to run automated tests. Having good grip on Javascript to work on Cypress is a must. There are cases where one would have to pass additional headers when making a request. Cypress lacks that feature and the task is to add support for that.

Getting started:

Go through the README for guidelines on file structure, formatting and instructions on how to set up and run Cypress.

In short:

cd cypress-tests
npm ci

Possible implementation:

The main intention here is to have the optimal and efficient solution. An in-efficient solution can give an idea about implementing more optimal solution as well.

  • Introduce a new optional environment variable to State in order to read additional headers
  • Create a function or a const at the top of commands that reads the cypress environment variable, something like below:
    const customHeaders = {
    	// passed in Cypress.env, say `customHeader="x-merchant-id": merchant_id,`
    	globalState.get(customHeader)
    };
    
  • In every request that is made in the Cypress.Commands.add(), pass ...customHeaders,
  • This can be optimized by intercepting the request before it is made by leveraging cy.intercept() in e2e

Additional info:

  • Language: Javascript
  • Difficulty: Medium

Submission Process:

  • Ask the maintainers for assignment of the issue, you can request for assignment by commenting on the issue itself.
  • Once assigned, submit a pull request (PR).
  • Maintainers will review and provide feedback, if any.
  • Maintainers can unassign issues due to inactivity, read more here.

Refer here for Terms and conditions for the contest.

Contributor guide