K6 has the page.screenshot
function, but I wonder if it can somehow - via Sobek - make use of mature Visual Regression Testing tools, such as BackstopJS (which works with Playwright, whose API k6 Browser was based off of). It would be a great way to do automated, comprehensive VRT testing.
If a JS tool like Backstop can’t be used, what would be the general approach to either making it compatible or making a custom extension - be it with Golang or JS - to allow for this?
Hi @nickchomey,
Welcome to our community forums! 
I’m sorry, but as of now, I’m not aware of any concrete way to perform VRTs with k6, although there’s probably somebody out there, from the community who tried luck and succeed.
If a JS tool like Backstop can’t be used, what would be the general approach to either making it compatible or making a custom extension - be it with Golang or JS - to allow for this?
I guess there’s multiple choices possible, including:
- If you know a Go library that’s capable to perform VRT given the contents (snapshot) of a concrete scenario, you can likely easily extend the k6 API with a custom extension, and use it in combination with
xk6-browser
. Like, passing the return from the call to Page.screenshot
to the JS API of your custom extension.
- If you know a tool like Backstop that can work with screenshots taken by another tool/code, then you could use the
xk6-browser
features to store the screenshots as needed by that tool, and then use that other tool afterwards, as a 2-step process.
- Finally, if you could try to use Backstop as a library, you could try to run on Sobek, but in such case you might need something like Backstop-Playwright but for Sobek.
I leave the choice on what to explore first up to you. Feel free to share your remaining doubts, if any, and to share your successes and insights from that research. Others might have interest in a similar solution.
Cheers!