I’m exploring options to modify my existing test so that certain steps execute only when I include a specific annotation/tag in Playwright. The test currently performs several assertions, and I want to extend it to add a few more without repeating the same actions. Specifically, I’m checking the previews of a message editor. I’d like to enhance it to also send the message, while still verifying the previews independently.
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
});
});