SlideShare a Scribd company logo
1 of 18
Download to read offline
ALEXEY SHPAKOV
Visual regression testing
easier than you think
Visual regression testing
gives you confidence there
are no unintended changes.
WHY BOTHER?
Complicated
setup
Flakiness High
maintenance
Slow
Y u no visual regression testing?
Simple setup Isolation Low
maintenance
Fast
Y u ?
IT’S BEEN IN THE AIR
voice.kadira.io/snapshot-testing-in-react-storybook-43b3b71cec4f
How do we approach it?
A separate build to collect
urls
Plan of
actions
Get stories
urls
Use urls for
visual regression
testing
const getUrl = (kind, name) =>
"/iframe.html?selectedKind=" + encodeURIComponent(kind)
+ "&selectedStory=" + encodeURIComponent(name);
const storyUrls = storybook.getStorybook().reduce(
(agg, { kind, stories }) => {
const urls = stories.map(
({ name }) => getUrl(kind, name)
);
return [...agg, ...urls];
}, []
Generate test casesPlan of
actions
Get stories
urls
Use urls for
visual regression
testing
storyUrls.forEach(url => {
vrLibrary.suite(‘default', (suite) => {
suite
.setUrl(url)
.setCaptureElements('html')
.capture('default');
});
});
JIRA Frontend VR testing
images in 1000 seconds
PhantomJS
/garris/BackstopJS
Visual regression testing library
Electron
/segmentio/niffy
Webdriver
/gemini-testing/gemini
Visual
regression
testing is
optional
Visual
regression
testing is
obligatory
STORE
SCREENSHOTS
DO NOT STORE
SCREENSHOTS
No interaction
Don’t perform any webdriver
interaction - create another
story instead
Useful tips
Skip stories
Some stories are not fit
Stop animations
Any inconsistency fails visual
regression testing
Automated dependencies
bumps
Future
To be continued…Automatically perform visual
regression tests for every pull
request
IF YOU DON’T WANT TO OWN IT
percy.io screener.io
ALEXEY SHPAKOV
Thank you

More Related Content

Similar to Visual regression testing: easier than you think

Automation Testing
Automation TestingAutomation Testing
Automation TestingRomSoft SRL
 
Testing micro services using testkits
Testing micro services using testkitsTesting micro services using testkits
Testing micro services using testkitsMaxim Novak
 
A better approach for testing microservices - introducing test kits in practice
A better approach for testing microservices - introducing test kits in practiceA better approach for testing microservices - introducing test kits in practice
A better approach for testing microservices - introducing test kits in practiceMaxim Novak
 
Google App Engine Developer - Day4
Google App Engine Developer - Day4Google App Engine Developer - Day4
Google App Engine Developer - Day4Simon Su
 
Mobile TechTalk - Interesting talks from NSConference 6
Mobile TechTalk - Interesting talks from NSConference 6Mobile TechTalk - Interesting talks from NSConference 6
Mobile TechTalk - Interesting talks from NSConference 6GlobalLogic Ukraine
 
Browsers with Wings
Browsers with WingsBrowsers with Wings
Browsers with WingsRemy Sharp
 
Altitude San Francisco 2018: Testing with Fastly Workshop
Altitude San Francisco 2018: Testing with Fastly WorkshopAltitude San Francisco 2018: Testing with Fastly Workshop
Altitude San Francisco 2018: Testing with Fastly WorkshopFastly
 
iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...
iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...
iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...Rudy Jahchan
 
Testing JavaScript Applications
Testing JavaScript ApplicationsTesting JavaScript Applications
Testing JavaScript ApplicationsThe Rolling Scopes
 
Provisioning in Microsoft Azure
Provisioning in Microsoft AzureProvisioning in Microsoft Azure
Provisioning in Microsoft Azureilagin
 
Wicket Security Presentation
Wicket Security PresentationWicket Security Presentation
Wicket Security Presentationmrmean
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)Igor Bronovskyy
 
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015Codemotion
 
Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETBen Hall
 
Deploying Artifacts to Oracle Cloud with FlexDeploy
Deploying Artifacts to Oracle Cloud with FlexDeployDeploying Artifacts to Oracle Cloud with FlexDeploy
Deploying Artifacts to Oracle Cloud with FlexDeployDalibor Blazevic
 
End to-end testing from rookie to pro
End to-end testing  from rookie to proEnd to-end testing  from rookie to pro
End to-end testing from rookie to proDomenico Gemoli
 
Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded...
Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded...Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded...
Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded...Peter Pilgrim
 
Protractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsProtractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsLudmila Nesvitiy
 

Similar to Visual regression testing: easier than you think (20)

Automation Testing
Automation TestingAutomation Testing
Automation Testing
 
Testing micro services using testkits
Testing micro services using testkitsTesting micro services using testkits
Testing micro services using testkits
 
Test-driven serverless
Test-driven serverlessTest-driven serverless
Test-driven serverless
 
A better approach for testing microservices - introducing test kits in practice
A better approach for testing microservices - introducing test kits in practiceA better approach for testing microservices - introducing test kits in practice
A better approach for testing microservices - introducing test kits in practice
 
Google App Engine Developer - Day4
Google App Engine Developer - Day4Google App Engine Developer - Day4
Google App Engine Developer - Day4
 
Mobile TechTalk - Interesting talks from NSConference 6
Mobile TechTalk - Interesting talks from NSConference 6Mobile TechTalk - Interesting talks from NSConference 6
Mobile TechTalk - Interesting talks from NSConference 6
 
Browsers with Wings
Browsers with WingsBrowsers with Wings
Browsers with Wings
 
Altitude San Francisco 2018: Testing with Fastly Workshop
Altitude San Francisco 2018: Testing with Fastly WorkshopAltitude San Francisco 2018: Testing with Fastly Workshop
Altitude San Francisco 2018: Testing with Fastly Workshop
 
iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...
iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...
iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deplo...
 
Testing JavaScript Applications
Testing JavaScript ApplicationsTesting JavaScript Applications
Testing JavaScript Applications
 
Provisioning in Microsoft Azure
Provisioning in Microsoft AzureProvisioning in Microsoft Azure
Provisioning in Microsoft Azure
 
Wicket Security Presentation
Wicket Security PresentationWicket Security Presentation
Wicket Security Presentation
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
 
Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NET
 
Deploying Artifacts to Oracle Cloud with FlexDeploy
Deploying Artifacts to Oracle Cloud with FlexDeployDeploying Artifacts to Oracle Cloud with FlexDeploy
Deploying Artifacts to Oracle Cloud with FlexDeploy
 
JavaFX Pitfalls
JavaFX PitfallsJavaFX Pitfalls
JavaFX Pitfalls
 
End to-end testing from rookie to pro
End to-end testing  from rookie to proEnd to-end testing  from rookie to pro
End to-end testing from rookie to pro
 
Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded...
Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded...Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded...
Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded...
 
Protractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsProtractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applications
 

Recently uploaded

"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 

Recently uploaded (20)

"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 

Visual regression testing: easier than you think

Editor's Notes

  1. Hi, my name is Alexey Shpakov and I work in JIRA Frontend Platform team. I am going to talk about visual regression testing.
  2. The idea behind it is simple: take a baseline screenshot of your component, perform changes, take another screenshot and compare it against the baseline.
  3. As any other type of testing, visual regression testing is there to increase confidence. Confidence that your change in one place has not broken anything completely unrelated in another. Confidence, that your component library did not introduce any breaking changes in the latest patch release. Confidence, that you have understood and addressed all the consequences of bumping a major version of that same library.
  4. If visual regression testing is so helpful, why so few people actually perform it? Often times visual regression testing is associated with end-to-end webdriver tests with all the corresponding drawbacks: 1. It is complicated to setup fresh test environment for every run 2. Webdriver tests are known for their flakiness and nobody believes flaky tests 3. The maintenance costs are high: you need to update your tests every time front end changes 4. Not to mention the slowness
  5. On the other end of the spectrum we have storybooks. They seem to be a complete opposite of end-to-end tests: 1. They are easy to setup - you already have a webserver that serves your stories, all you need to provide is render code 2. Isolation - you can simply stub all the data your components require, hence, no need for a server and AJAX calls or dependency on other components 3. Low maintenance - stories are just another consumer of component APIs, once you add static typing, there is no way you might ever forget to update them 4. Fast - they are pretty fast, as you don’t need to start the whole application to run them In general, storybooks allow you to render components in any state. It is helpful for development and for showcasing components' capabilities. If you don't use storybooks already, you definitely should.
  6. Storybooks allow us to render all components in their various states using a dedicated webserver... Why can't we use that for vr testing?
  7. Apparently, I am not the first to think about it. In fact, one of storybook developers suggested that option a year ago. Unfortunately, it has never landed in storybook. Let’s assume we have a visual regression library at hand. What do we need to make it work with storybook?
  8. The first naive idea that comes to mind is to write a script that will click through the stories on the left and take a screenshot on the right. That’s something. The obvious drawbacks is the webdriver flakiness. Just imagine clicking through a thousand stories - what could potentially go wrong? Another issue is this approach is difficult to run in parallel. As it happens, the iframe on the right has a well-defined url you can use. You can even generate a correct url for it given story kind and story name.
  9. The question is, how do we get those? We created a separate a separate build for that.
  10. Once we have all the stories and their kinds, we can generate test cases for our visual regression testing tool. The fact we generate our tests based on existing stories means we don’t need to maintain vr tests project separately.
  11. I’d like to share our journey to visual regression testing.
  12. At first, we looked at PhantomJS-based solution. It’s a headless browser and everybody uses it to test pages. There is thing about it, nobody tells you though. Which browser is it based on? It is an ancient version of QtWebkit. It took me a couple of hours and a number of shims just to make it render a page in our storybook… only to realize it does not support the css we use. Fortunately, BackstopJS we used supports Firefox-based engine as well. Switching to it helped a lot. Not headless anymore, but at least it works. The next question that popped up was to check the browser distribution among our customers. I haven’t spent much time with Niffy as the next concern was about poor IE users. Even though the majority of customers use Chrome, we should still care about IE. So, we’ve moved to the dreaded Webdriver-based solution. And it worked alright: 1. It allows to test in Chrome - most widely used browser. 2. It also allows to test in other browsers (IE) 3. It allows to offload testing to a third-party, e.g. Browsersrack or Saucelabs. 4. You can run them in parallel almost for free from within docker container.
  13. This is a very controversial matter. When you store screenshots, you save time for generating a baseline. It also allows you to have nice diffs in pull requests and ensures every change doesn’t go unnoticed. At the same time it bloats your codebase, changes dev loop and requires developers to regenerate the screenshots all the time. Not to mention merge conflicts. We’ve joined the dark side and decided to have visual regression testing as an optional tool.
  14. During our use of visual regression testing we aggregated a couple of best practices. 1. stop animation - an obvious one, once you have any animation, chances are you are never going to get a pass for your visual regression test 2. no interaction - interaction causes flakiness. If there is a number of actions you need to perform in order to put your component into a state for a screenshot, why don’t you create a story with that state to begin with? 3. add possibility to skip stories - some stories might simply be not fit for visual regression testing
  15. We are only in the beginning of our journey with visual regression testing. In future we intend to perform visual regression testing for all the pull requests created using CI. Also, we intend to perform automated dependencies bumps and having visual regression testing is crucial for that.
  16. If you want all this awesomeness but don’t want to maintain it, there are paid services available online that can help you.
  17. In conclusion, I suggest you give visual regression testing a spin. Who knows, maybe it will prevent a bug or two in production ;).