← Back to Discord Forum

Possible to do slowMo for just a single test?

The test code below only passes when I do slowMo=1000 in headless. I know I am not supposed to use slowMo, but I am going by all the recommendations by playwright and it still only passes with slowMo. Is there a way to do just slowMo for a single test so I do not have to slow down the whole test suite?

Note: I am using mock data, not live data, so there is no lag in that respect.

it('should update max value in input box from slide adjustment and save', async({ page }) => {
        const responsePromise = page.waitForResponse(apiUrl);
        const targetPosition = { x: 100, y: 10 };
        const el = page.getByText('Match is probable');
        const el0 = page.locator('#mat-input-1');
        await page.getByRole('slider').nth(1).dragTo(el, {targetPosition});
        await expect(el0).toHaveAttribute('ng-reflect-model', '75');
        const response = await responsePromise;

This thread is trying to answer question "Is there a way to apply slowMo to a single test instead of the entire test suite?"

6 replies

If you are using the Playwright Test runner you can do this, along with overwriting the default timeout for your suite.

test("slow test", async ({ page }) => {

thank you, I am using p test runner

it.slow(); isn't really helping. and I am not supposed to use waitForTimeout. Any ideas why?

it.only('should exit when save and exit button is pressed', async ({ page }) => {
        await page.getByRole('button', { name: 'EDIT' }).click();                     
        await page.getByText('SAVE AND EXIT', { exact: true }).click();               

Can you link the docs for p test runner, first I’ve heard of this.


Never wait for timeout in production. Tests that wait for time are inherently flaky. Use Locator actions and web assertions that wait automatically.

I am using locator actions and web assertions that wait. And it's what I been told on here before from @mxschmitt

I think playwright might have issues with the page transition animations in Angular ... if I was to guess some of these race condition issues? Or maybe just with Angular in general?


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 }) => {
  // 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.

Related Discord Threads

AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

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 luc@ray.run.