在柏树测试运行之前,检查功能标志是否打开或关闭
我正在尝试为尚未启用的功能编写测试(隐藏在功能标志后面);我可以致电一个端点,以检查应用程序功能标志是否打开或关闭,我写了一个函数。
我的下一个任务是在功能标志打开的情况下,实现柏树仅运行特定测试的方法。如何实现我写的方法?我必须在cypress.config中的某个地方实现检查吗?
谢谢!
该方法的代码
checkTemplateFeatureFlag(): Chainable<Temp> {
return (new Cypress.Promise(resolve => {
cy.request({
method: 'GET',
url: `ENDPOINT_HERE`
}).then(resp => {
const array = JSON.parse(resp.body);
const foundFlag = !!array.find(
(obj: { flag_name: string; active: boolean }) =>
obj.flag_name === 'FLAG_NAME' && obj.active
);
resolve(foundFlag);
});
}) as unknown) as Chainable<Temp>;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
跳过测试(或
描述
块)的一种简单方法是使用function()
compand cownbacks访问 this ,然后有条件地调用this.skip()
。您还需要在单独的块中调用
chceptemplatefeatureflag()
,例如theeach()
,因为它具有异步内置。A simple way to skip tests (or
describe
blocks) dynamically is to usefunction()
form callbacks to accessthis
, then conditionally callthis.skip()
.You will also need to call
checkTemplateFeatureFlag()
in a separate block, say abeforeEach()
, since it has async internals.