我们最近在应用程序中安装了datadogRUM,现在在我的柏树测试中启动了这么多DD事件,导致超时和失败。
我尝试过多种方式的cy.intercept:
cy.intercept('POST', 'https://rum.browser-intake-datadoghq.com/*', {
statusCode: 202,
body: {
},
}).as('datadogRUM');
cy.intercept('POST', 'https://rum-http-intake.logs.datadoghq.com/*', {});
cy.intercept(/\.*datadog.*$/, (req) => {
console.log('DATADOG INTERCEPTED');
req.reply("console.log('datadog intercept');");
});
cy.intercept({
method: 'POST',
url: '/\.*datadog.*$/'
}, req => {
req.destroy();
});
cy.intercept('POST', 'https://rum-http-intake.logs.datadoghq.com/*', { forceNetworkError: true });
只是为了开始。我觉得我试过了所有可能的变体。我还在我的cypress.json文件夹中创建了一个/cypress文件
{
"blockHosts": "*datadoghq.com/*"
}
我在我的网络选项卡中收到了数百个电话,当我截取这些电话时,我会在https://rum.browser-intake-datadoghq.com/api/v2/rum
预览的情况下接收到它们。他们都显示纯蓝线,好像他们被拦截和封锁。当我将拦截设置为别名时,我会在我的柏树跑步窗口中看到别名。但是在任何地方都没有503
s或404
s。页面仍然充满了事件,柏树被重载,我的测试超时。
我甚至尝试将data-dog-rum.ts
从src/utils文件夹复制到cypress/utils,或者注释掉所有内容,或者将sampleRate
设置为0
,没有骰子。
编辑:我可以通过添加
Cypress.on('uncaught:exception', () => {
// returning false here prevents Cypress from
// failing the test
return false;
});
对于我的support/index.js
,但是现在我是否在我的测试中添加一个cy.intercept没有任何区别。页面仍然充斥着datadog请求,不管它们是否以200/未决/取消的形式返回,它们仍然会将规范中的单个it块延迟到运行60秒而不是大约10秒的时间。
发布于 2022-10-05 23:25:37
您可以使用javascript在routeHandler中执行存根。
cy.intercept('*', (req) => { // look at everything
if (req.url.includes('datadoghq')) { // add more conditions if needed
req.reply({}) // prevent request reaching the server
}
})
blockhosts
应该与
只传递主机
{
"blockHosts": "*datadoghq.com"
}
https://stackoverflow.com/questions/73966402
复制相似问题