|
| 1 | +// Visually test visualize.html on localhost |
| 2 | +var htmlPath = "http://localhost:8003/visualize.html" |
| 3 | + |
| 4 | +var fs = require('fs'); |
| 5 | +var path = fs.absolute(fs.workingDirectory + '/phantomcss.js'); |
| 6 | +var phantomcss = require(path); |
| 7 | + |
| 8 | +casper.test.begin('Testing ' + htmlPath, function (test) { |
| 9 | + // boring setup code taken from PhantomCSS demo |
| 10 | + phantomcss.init({ |
| 11 | + rebase: casper.cli.get( "rebase" ), |
| 12 | + // SlimerJS needs explicit knowledge of this Casper, and lots of absolute paths |
| 13 | + casper: casper, |
| 14 | + libraryRoot: fs.absolute( fs.workingDirectory + '' ), |
| 15 | + screenshotRoot: fs.absolute( fs.workingDirectory + '/screenshots' ), |
| 16 | + failedComparisonsRoot: fs.absolute( fs.workingDirectory + '/demo/failures' ), |
| 17 | + addLabelToFailedImage: false, |
| 18 | + }); |
| 19 | + |
| 20 | + casper.on('remote.message', function(msg) {this.echo(msg);}); |
| 21 | + casper.on('error', function (err) {this.die( "PhantomJS has errored: " + err );}); |
| 22 | + casper.on('resource.error', function (err) {casper.log( 'Resource load error: ' + err, 'warning' );}); |
| 23 | + |
| 24 | + |
| 25 | + casper.start(htmlPath); |
| 26 | + casper.viewport(1440, 900, function () { |
| 27 | + phantomcss.screenshot('#pyInputPane', 'pyInputPane'); |
| 28 | + }); |
| 29 | + |
| 30 | + // click on one example code for each language |
| 31 | + casper.then(function() { |
| 32 | + casper.click("#aliasExampleLink"); |
| 33 | + phantomcss.screenshot('#pyInputPane', 'pyInputPane'); |
| 34 | + }); |
| 35 | + |
| 36 | + casper.then(function() { |
| 37 | + casper.click("#tortureLink"); |
| 38 | + phantomcss.screenshot('#pyInputPane', 'pyInputPane'); |
| 39 | + }); |
| 40 | + |
| 41 | + casper.then(function() { |
| 42 | + casper.click("#javaVarLink"); |
| 43 | + phantomcss.screenshot('#pyInputPane', 'pyInputPane'); |
| 44 | + }); |
| 45 | + |
| 46 | + casper.then(function() { |
| 47 | + casper.click("#jsDatatypesExLink"); |
| 48 | + phantomcss.screenshot('#pyInputPane', 'pyInputPane'); |
| 49 | + }); |
| 50 | + |
| 51 | + casper.then(function() { |
| 52 | + casper.click("#tsGreeterExLink"); |
| 53 | + phantomcss.screenshot('#pyInputPane', 'pyInputPane'); |
| 54 | + }); |
| 55 | + |
| 56 | + casper.then(function() { |
| 57 | + casper.click("#rubyConstantsLink"); |
| 58 | + phantomcss.screenshot('#pyInputPane', 'pyInputPane'); |
| 59 | + }); |
| 60 | + |
| 61 | + casper.then(function() { |
| 62 | + casper.click("#cMengThesisLink"); |
| 63 | + phantomcss.screenshot('#pyInputPane', 'pyInputPane'); |
| 64 | + }); |
| 65 | + |
| 66 | + casper.then(function() { |
| 67 | + casper.click("#cppFirstLink"); |
| 68 | + phantomcss.screenshot('#pyInputPane', 'pyInputPane'); |
| 69 | + }); |
| 70 | + |
| 71 | + |
| 72 | + // run all the tests: |
| 73 | + casper.then(function now_check_the_screenshots() { |
| 74 | + phantomcss.compareAll(); // compare screenshots |
| 75 | + }); |
| 76 | + |
| 77 | + casper.run(function() { |
| 78 | + //phantomcss.getExitStatus() // pass or fail? |
| 79 | + casper.test.done(); |
| 80 | + }); |
| 81 | +}); |
0 commit comments