From fe66e3011753611767fd4b7a0cddf0d94a09f09d Mon Sep 17 00:00:00 2001 From: belaletech Date: Thu, 13 Feb 2025 16:15:05 +0530 Subject: [PATCH 1/2] custom-header --- .../integration/examples/custom-header.spec.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 cypress/integration/examples/custom-header.spec.js diff --git a/cypress/integration/examples/custom-header.spec.js b/cypress/integration/examples/custom-header.spec.js new file mode 100644 index 0000000..85a6d7f --- /dev/null +++ b/cypress/integration/examples/custom-header.spec.js @@ -0,0 +1,15 @@ +describe('Validate Custom Headers', () => { + it('Should send and validate custom headers', () => { + cy.request({ + method: 'GET', + url: 'https://httpbin.org/headers', // Public API to test headers + headers: { + 'x-custom-header': 'test-valueee' // Custom header + } + }).then((response) => { + // Validate that the response contains the custom header + expect(response.status).to.eq(200); + expect(response.body.headers['X-Custom-Header']).to.equal('test-value'); + }); + }); +}); From 4173cbef0fae480a2131720814cc0d534a745d5a Mon Sep 17 00:00:00 2001 From: belaletech Date: Thu, 13 Feb 2025 16:16:03 +0530 Subject: [PATCH 2/2] update-readme-file --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3f79e90..34fdc77 100644 --- a/README.md +++ b/README.md @@ -303,7 +303,13 @@ To stay updated with the latest features and product add-ons, visit [Changelog]( [](https://accounts.lambdatest.com/register) - + ## Validate Custom Headers + +Custom headers are essential when making API requests to include metadata such as authentication tokens, tracking information, or custom identifiers. This test ensures that custom headers are correctly sent and received using Cypress. + +The test sends a GET request to `https://httpbin.org/headers` with a custom header (`x-custom-header`). It then validates that the server receives the correct header in the response. + + ## We are here to help you :headphones: * Got a query? we are available 24x7 to help. [Contact Us](support@lambdatest.com)