Rather new to Testcafe, i have constructed a logger and loggerResponseBody function. But when running the tests, it gives me typeerrors. Also the tests used to work some time ago.
Code of logger and loggerResponseBody: (the logger and loggerResponseBody are in different files)
import { RequestLogger } from 'testcafe'
import { BASE_URL } from '../consts/generic'
export const logger = (endpoint, method = 'GET') =>
RequestLogger(
{ url: `${BASE_URL}/api/v1/${endpoint}/`, method },
{
logResponseHeaders: true,
logResponseBody: true
}
)
export const loggerResponseBody = (logger, requestNumber = 0) =>
JSON.parse(logger.requests[requestNumber].response.body.toString())
Which gives the error:
1) TypeError: Cannot read property 'response' of undefined
Browser: Chrome 85.0.4183 / Linux 0.0.0
10 | logResponseBody: true
11 | }
12 | )
13 |
14 |export const loggerResponseBody = (logger, requestNumber = 1) =>
> 15 | JSON.parse(logger.requests[requestNumber].response.body.toString())
16 |
Aucun commentaire:
Enregistrer un commentaire