有没有办法使用剧作家注释来运行特定的测试步骤

问题描述 投票:0回答:1

我正在探索修改现有测试的选项,以便仅当我在 Playwright 中包含特定注释/标签时才执行某些步骤。该测试当前执行多个断言,我想对其进行扩展以添加更多断言,而无需重复相同的操作。具体来说,我正在检查消息编辑器的预览。我想增强它以发送消息,同时仍然独立验证预览。

test('Test for some feature 1', async ({page}) => {
   test.step('Step 1', async() => {
     //Few assertions here
    });
  
  test.step('Step 2', async() => {
    //Few assertions here
    });
 
//This step should only run if I pass a certain annotation/tag
 test.step('Step 3', {tag: ['@featureX']}, async() => {
 //This should run only if I pass an annotation say @featureX
 });
});
javascript playwright playwright-test
1个回答
0
投票

我不相信 test.step 支持任何类型的标记功能,但是我不明白为什么你不能通过检查环境变量来实现你正在寻找的东西,当你想要额外的步骤时你可以设置它运行而不设置,当你不这样做时。

© www.soinside.com 2019 - 2024. All rights reserved.