garris / BackstopJS

Catch CSS curve balls.
http://backstopjs.org
MIT License
6.69k stars 604 forks source link

Doing complex interactions using playwright #1393

Open edi9999 opened 2 years ago

edi9999 commented 2 years ago

I have been using backstop for 2 weeks now on my project docxtemplater.com .

I'm very happy because it will catch many regressions that would occur on the website.

I have a feature request that would make the experience for me even better.

It would be to be allow to run any playwright script before doing the snapshot.

For example, one could do :

    {
      "label": "Dashboard",
      "url": "http://localhost:9432/dashboard",
      "playwright_action": "open_secret_dashboard",
      "selectors": ["viewport"]
    }

and then in open_secret_dashboard.js :

import { test, expect } from '@playwright/test';

test('basic test', async ({ page }) => {
      // Text input
    await page.fill('#name', 'Peter');
    await page.fill('#password', 'Peter');
    await page.click('button#submit');
    await page.click('.tab-dashboard');
    await Promise.all([
      page.waitForSelector('#dashboard-customers'),
      page.waitForSelector('#dashboard-providers')
    ]);
});

The snapshot would be taken right after the playwright script runs.

After posting the issue, I found out that maybe this usecase could be done from playwright itself :

https://hackernoon.com/visual-regression-testing-with-playwright (not using backstop at all)

edi9999 commented 2 years ago

I have seen https://github.com/garris/BackstopJS/issues/657 but it seems that the usecase was just to do a few clicks, not to do entering of data + clicks.

I thought that letting the user pass a script would allow the user to do whatever they want before the screenshot, and that could be done simply in backstop since it is just delegating the problem to playwright.