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

200
Views
Can I get the network requests in testcafe from the beforeEach?

I saw this page from testcafe documentation, but it all points toward tests.

import { RequestLogger } from 'testcafe';
const logger = RequestLogger({ logResponseBody: true, logRequestBody: true });
const methodCallInBeforeEach = async => {console.log(logger.requests)}

Every time my logger is empty, as if I had no requests. This works if I try to get the info from a test, but didn't manage to do it from the beforeEach. Is that even possible or am I missing something?

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

0

I prepared a sample that demonstrates that the logger.requests works as expected inside the beforeEach hook:

import { RequestLogger, Selector } from 'testcafe';

const headerLogger = RequestLogger(/testcafe/, {
    logRequestHeaders:  true,
    logResponseHeaders: true,
});

fixture `f`
    .page `https://testcafe.io`
    .requestHooks(headerLogger)
    .beforeEach(async t => {
        await t.click(Selector('a').withText('Docs'));

        console.log(headerLogger.requests.map(r => r.request.url));
    });

test(`t`, async t => {

});

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!