Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
How do i modify browser network call request body using TestCafe

I want to modify the API request body by interrupting the network calls using Testcafe. I am aware I can modify the response body but I want to modify the request body instead, using testCafe's RequestMock().

Load the web app > Find the API using filter > Modify the request body > Pass the actual response to the web app

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can implement a Custom Request Hook to modify the request body.

For example:

import { RequestHook } from "testcafe";

export class MyRequestHook extends RequestHook {
    onRequest (event) {
        if (event.requestOptions?.body)
            event.requestOptions.body = Buffer.from(event.requestOptions.body, "utf8");
    }
    onResponse (event) {}
}

const customHook = new MyRequestHook(/api/); 

fixture`Modify Request Body`
    .page`http://localhost:3001`
    .requestHooks(customHook);

test('Test', async t => {
    await t.click('button');
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!