juspay/hyperswitch

[CYPRESS_FRAMEWORK] Pass custom-headers before making a request

Open

#5,912 创建于 2024年9月16日

在 GitHub 查看
 (5 评论) (0 反应) (0 负责人)Rust (4,676 fork)batch import
E-mediumgood first issuehacktoberfesthelp wantedjavascript

仓库指标

Star
 (42,690 star)
PR 合并指标
 (平均合并 6天 22小时) (30 天内合并 213 个 PR)

描述

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.

贡献者指南