juspay/hyperswitch

[CYPRESS_FRAMEWORK] Pass custom-headers before making a request

Open

#5912 aperta il 16 set 2024

Vedi su GitHub
 (5 commenti) (0 reazioni) (0 assegnatari)Rust (4676 fork)batch import
E-mediumgood first issuehacktoberfesthelp wantedjavascript

Metriche repository

Star
 (42.690 star)
Metriche merge PR
 (Merge medio 6g 22h) (213 PR mergiate in 30 g)

Descrizione

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.

Guida contributor