Regression testing for styling and layout of web applications

前端 未结 5 415
-上瘾入骨i
-上瘾入骨i 2021-02-04 10:55

I realise this is a non-trivial task, but is there a way to regression test the styling and rendered layout of a web application?

I\'ve found it straightforward to unit t

5条回答
  •  一向
    一向 (楼主)
    2021-02-04 11:32

    If you're developing in Ruby, take a look at the rspec-page-regression gem. It's an RSpec plugin that lets you compare requested page snapshots against an expected image. It works with Poltergeist, which is a Capybara driver that uses PhantomJS and supports rendering page snapshots.

    Rspec-page-regression provides an RSPec matcher that lets you do things like

    context "user page" do
      before(:each) do
        visit user_path
      end
    
      it { page.should match_expected }
    
      context "popup help" do
        before(:each) do
          click_button "Help"
        end
    
        it { page.should match_expected }
      end
    end
    

    And it provides a mechanism to manage the expectation images.

    Disclaimer: I'm the author of the gem.

提交回复
热议问题