└── responsive-screenshots.coffee /responsive-screenshots.coffee: -------------------------------------------------------------------------------- 1 | # Variables for the tests. 2 | url = "http://georgia.gov" 3 | breakpoints = [ 4 | [1280, 1024], 5 | [960, 640], 6 | [480, 320] 7 | ] 8 | links = [ 9 | "/", 10 | "/search?query=georgia", 11 | "/agency-list", 12 | "/environment", 13 | ] 14 | 15 | casper = require('casper').create({ 16 | #verbose: true, 17 | logLevel: "debug", 18 | }) 19 | 20 | casper.test.comment "#{url} - Screenshots to test responsive breakpoints" 21 | 22 | casper.start() 23 | 24 | # Needed so that the first screenshot works, sadly. 25 | casper.then -> 26 | @viewport breakpoints[0][0], breakpoints[0][1] 27 | @open url + links[0] 28 | @echo "Opening URL #{url + links[0]}." 29 | @wait 2000 30 | 31 | openPages = -> 32 | @each links, (self, link) -> 33 | fullUrl = url + link 34 | # Open a URL. 35 | @thenOpen fullUrl, -> 36 | @test.assertHttpStatus 200, "URL #{fullUrl} was found." 37 | # Capture an image. 38 | @capture fullUrl.replace(/[^a-zA-Z0-9]/gi,'-').replace(/^https?-+/, '') + breakpoints[currentBreakpoint - 1][0] + ".png" 39 | 40 | currentBreakpoint = 0 41 | 42 | check = -> 43 | if breakpoints[currentBreakpoint] 44 | @viewport breakpoints[currentBreakpoint][0], breakpoints[currentBreakpoint][1] 45 | openPages.call @ 46 | currentBreakpoint++ 47 | @run check 48 | else 49 | @echo "All done." 50 | @test.renderResults true 51 | @exit 52 | 53 | casper.run check 54 | 55 | --------------------------------------------------------------------------------