[Feature] Add possibility to compare screenshots not only in scope of PW test() function
Use case
In our project we're using gherkin scenarios (Cucumber as test runner) without defined PlaywrightTestConfig
All expect methods work fine except expect(page).toHaveScreenshot() and expect(page).toMatchSnapshot().
I got the following issue: Error: toHaveScreenshot() must be called during the test:

Limitation
For now using expect(page).toHaveScreenshot() and expect(page).toMatchSnapshot() methods is possible only in scope of PW test() function since the matcher checks testInfo and takes a snapshot dir path from there: https://github.com/microsoft/playwright/blob/main/packages/playwright-test/src/matchers/toMatchSnapshot.ts#L292-L298
Feature
It will be great to have possibility to use expect(page).toHaveScreenshot() and expect(page).toMatchSnapshot() methods without defined PlaywrightTestConfig and out of the PW test() scope (e.g. if some other test runner is using) - to define absolute path to reference snapshot directly in methods (e.g. like optional parameter expect(page).toHaveScreenshot({ path: PATH_TO_REFERENCE_SCREENSHOT }) or expect(page).toHaveScreenshot(REFERENCE_SCREENSHOT_NAME, { snapshotDir: PATH_TO_CUSTOM_REFERENCE_SCREENSHOT_DIRECTORY })) without using snapshot dir path from testInfo if this optional parameter is using.
Having the exact same problem right now where all other tests work as expected, only the one for comparing screenshots does not: https://gitlab.com/mvanremmerden/gitdock/-/merge_requests/108/diffs#ac6e7587d6b6d54c7b14db36e902be005c853c71_16_17
Relates to https://github.com/microsoft/playwright/issues/11975 & #14539
Having the same issue too. Did anyone found an alternative solution ?
I am facing the same issue and raised the problem in a different #15800 . Is there any solution to use screen comparison with cucumber runner?
Still no fix or workaround?
I am facing the same issue.
Still have this issue now.
like to have it as well
In general not sure if such comments are more helpful or annoying. But I would also really like to have this feature. It is possible to use Playwright almost completely with a different test runner. Unfortunately not screenshots.
I am having the same issue
having the same issue
We would love to have this feature !
PLEASE !
This feature will be very helpful for the projects with cucumber framework. Please add this feature