var http = require('http'); var express = require('express'); var backstop = require('backstopjs'); var path = require('path'); var app = express(); app.use("http://www.cnblogs.com/", express.static(path.join(__dirname ,'../html/'))); sever = http.createServer(app).listen('3000', function() { //Ö´ÐÐbackstop backstop('reference').then(function () { sever.close(); }); });
ÔÚÎÒÃÇÖع¹ÏîĿ֮ǰ£¬¿ÉÒÔÔËÐÐÕâ¸ö½Å±¾£¬ÕâÑù¾Í¿ÉÒÔÉú³ÉÑù°åͼ£¬ÎªÖع¹ºó×ö²âÊÔʹÓá£
Éú³ÉµÄÑù°åͼ¸ñʽÈçÏÂͼ£º
3.²âÊÔ
ÔÚÖع¹ÑùʽºóÖ´ÐÐÃüÁîÐУº
backstop test
ͬÑùΪÁËÄܹ»ºÍ·þÎñÆ÷¼¯³É£¬ÎÒÃÇʹÓÃcommonjsÄ£¿éµÄÐÎʽµ÷ÓÃbackstopjs£¬È磺
var http = require('http'); var express = require('express'); var backstop = require('backstopjs'); var path = require('path'); var app = express(); app.use("http://www.cnblogs.com/", express.static(path.join(__dirname ,'../html/'))); sever = http.createServer(app).listen('3000', function() { //Ö´ÐÐbackstop backstop('test').then(function () { sever.close(); }); });
Èç¹ûÐÂÉú³ÉµÄͼƬºÍÑù°åͼ²»Ò»Ñù£¬¾Í»á±¨´í¡£Éú³ÉµÄ±¨¸æÓÐÁ½ÖÖÐÎʽ——ÃüÁîÐб¨¸æºÍä¯ÀÀÆ÷±¨¸æ£¬ÕâÀïչʾµÄÊÇä¯ÀÀÆ÷±¨¸æ½á¹û£º
Ïêϸdemo¿ÉÒԲ鿴https://github.com/laden666666/BackstopJSDemo¡£
ÕâÀïչʾÁËbackstopjs×ö×Ô¶¯»¯»Ø¹é²âÊÔµÄÒ»¸öÀý×Ó£¬backstopjs»ù±¾Äܹ»Âú×ãÎÒÃǵÄÐèÇ󣬿ÉÒÔÖ§³ÖÏìӦʽ²¼¾Ö²âÊÔ¡¢¿ÉÒԺͷþÎñÆ÷¼¯³É¡¢¿ÉÒÔÇл»ä¯ÀÀÆ÷ÒýÇæµÈ¡£²»¹ýÒ²ÓÐȱµã£¬ÒòΪPhantomJSºÍSlimerJS·Ö±ðÊÇʹÓÃwebkit(blink£¬chromeµÄÄÚºË)ºÍ Gecko (FirefoxÄÚºË)×÷ΪÄںˣ¬Òò´ËÎÞ·¨Ä£Äâieä¯ÀÀÆ÷×ö²âÊÔ£¬ÏÂÒ»²½×¼±¸¼ÌÐøÑо¿²âÊÔieµÄ·½·¨¡£
¡¡