Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Make step.skip conditional #34460

Open
kodringer opened this issue Jan 23, 2025 · 1 comment
Open

[Feature]: Make step.skip conditional #34460

kodringer opened this issue Jan 23, 2025 · 1 comment
Assignees
Labels

Comments

@kodringer
Copy link

🚀 Feature Request

I’d like to request the ability to add condtion for step.skip() like for test.skip()

Example

For example some test steps are needed for desktop views and no needed for mobile views or vice versa.

Motivation

Make tests more flexible

@irwanhub2016
Copy link

interested, maybe currently you can handle using helper function like this

helper

async function maybeSkip(condition: boolean, stepFunction: () => Promise<void>) {
    if (!condition) {
        await stepFunction();
    } else {
        console.log('Step skipped due to condition.');
    }
}

test

test('using helper function to skip step', async ({ page }) => {
    await page.goto('https://example.com');

    const shouldSkipStep = true;

    // skip test
    await maybeSkip(shouldSkipStep, async () => {
        await page.click('#some-button');
    });

    await page.fill('#input-field', 'Hello Playwright');
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants