Sure, you can apply slowmo to just one test in Playwright! You can use the test.slow()
method to mark a specific test as "slow". This gives it triple the default timeout. Here's how you do it:
import { test } from '@playwright/test';
test('slow test', async ({ page }) => {
test.slow();
// Your test code goes here
});
By using test.slow()
in your test function, it gets more time to complete before timing out. But remember, you can't use test.slow()
in a beforeAll
or afterAll
hook.
If you want to apply slowmo to all tests in a file or a test.describe()
group, you can use the conditional version of test.slow()
. Here's how:
import { test } from '@playwright/test';
test.slow(({ browserName }) => browserName === 'webkit');
test('slow in WebKit 1', async ({ page }) => {
// Your code goes here
});
test('skip in WebKit 2', async ({ page }) => {
// Your code goes here
});
In this case, all tests in this file or group will be "slow" if the condition browserName === 'webkit'
is true. This lets you apply slowmo to specific tests based on certain conditions. So, with test.slow()
, you can mark a specific test as "slow" or apply it conditionally to multiple tests.
If you still have questions, please ask a question and I will try to answer it.
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].