Run a test on different viewports

Hi,

I want to implement a test, which could be executed across some viewports (desktop/mobile for example).

in Cypress it’s possible to do smth like this

Cypress._.each(["macbook-15", "iphone-x"], viewport => {
    it(`some test on ${viewport}`, function() {
      cy.viewport(viewport)
    
      // condition if tests differ
      if (viewport === "iphone-x") {
        // do smth
      }
      // do smth

so this test will be executed 2 times (2 viewports).
is there a similar way to achieve that in CodeceptJS with Playwright?
Thanks

Yes. But instead of

cy.viewport(viewport)

you need your own methods to update the configuration. In short, you need to pass the user agent and the sizes of a device or, if a device is present in the Chrome dictionary of mobile devices, just its name.

Answers here (Possibility to use devtools on chrome browser using CodeceptJS) show the configuration for Chrome in Puppeteer and WebDriver helpers

The lists of user agents and sizes of mobile devices, you can find on the internet.