我從 testcafe 檔案中看到了這個頁面,但它都指向測驗。
import { RequestLogger } from 'testcafe';
const logger = RequestLogger({ logResponseBody: true, logRequestBody: true });
const methodCallInBeforeEach = async => {console.log(logger.requests)}
每次我的記錄器是空的,就好像我沒有請求一樣。如果我嘗試從測驗中獲取資訊,但沒有設法從 beforeEach 中獲取資訊,則此方法有效。這甚至可能還是我錯過了什么?
uj5u.com熱心網友回復:
我準備了一個示例,證明 logger.requests 在 beforeEach 鉤子中按預期作業:
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 => {
});
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/424118.html
標籤:javascript 测试 自动化测试 e2e-测试 测试咖啡馆
