diff --git a/package.json b/package.json index 46dd6b3..fce167c 100644 --- a/package.json +++ b/package.json @@ -47,11 +47,13 @@ }, "devDependencies": { "autoprefixer": "^6.3.6", + "backstopjs": "^1.3.5", "browser-sync": "^2.13.0", "node-sass": "^3.7.0", "npm-run-all": "^2.1.1", "onchange": "^2.4.0", - "postcss-cli": "^2.5.2" + "postcss-cli": "^2.5.2", + "slimerjs": "^0.906.2" }, "engines": { "node": "^6.0.0" @@ -63,6 +65,7 @@ "build": "npm-run-all sass autoprefixer banner", "watch": "onchange src -- npm run build", "serve": "browser-sync start -s test --ss dist -f dist", - "start": "npm-run-all -p watch serve" + "start": "npm-run-all -p watch serve", + "test": "cd node_modules/backstopjs && npm run test -- --configPath=../../test/visual/backstop.config.js && cd ../../" } } diff --git a/test/visual/backstop.config.js b/test/visual/backstop.config.js new file mode 100644 index 0000000..53a10c8 --- /dev/null +++ b/test/visual/backstop.config.js @@ -0,0 +1,33 @@ +module.exports = { + viewports: [ + { name: 'phone_v', width: 320, height: 480 }, + { name: 'phone_h', width: 480, height: 320 }, + { name: 'tablet_v', width: 768, height: 1024 }, + { name: 'tablet_h', width: 1024, height: 768 }, + { name: 'laptop', width: 1280, height: 800 }, + { name: 'desktop', width: 1920, height: 1080 } + ], + scenarios: [{ + label: 'Milligram | A minimalist CSS framework.', + url: 'http://localhost:3000', + hideSelectors: [], + removeSelectors: ['.__bs_notify__'], + selectors: ['body'], + readyEvent: null, + delay: 500, + misMatchThreshold: 0.1, + onBeforeScript: 'onBefore.js', + onReadyScript: 'onReady.js' + }], + paths: { + bitmaps_reference: '../../test/visual/reference', + bitmaps_test: '.tmp', + casper_scripts: '../../test/visual/fixtures', + compare_data: '.tmp/compare.json' + }, + engine: 'slimerjs', + report: ['browser'], + casperFlags: [], + debug: false, + port: 3002 +} diff --git a/test/visual/fixtures/onBefore.js b/test/visual/fixtures/onBefore.js new file mode 100644 index 0000000..6760703 --- /dev/null +++ b/test/visual/fixtures/onBefore.js @@ -0,0 +1,4 @@ +module.exports = function(casper, scenario, vp) { + casper.echo('onBeforeEach.js', 'INFO'); + casper.wait(50); +}; diff --git a/test/visual/fixtures/onReady.js b/test/visual/fixtures/onReady.js new file mode 100644 index 0000000..3728804 --- /dev/null +++ b/test/visual/fixtures/onReady.js @@ -0,0 +1,4 @@ +module.exports = function(casper, scenario, vp) { + casper.echo('onReady.js', 'INFO'); + casper.wait(50); +}; diff --git a/test/visual/reference/0_0_body_0_phone_v.png b/test/visual/reference/0_0_body_0_phone_v.png new file mode 100644 index 0000000..3524754 Binary files /dev/null and b/test/visual/reference/0_0_body_0_phone_v.png differ diff --git a/test/visual/reference/0_0_body_1_phone_h.png b/test/visual/reference/0_0_body_1_phone_h.png new file mode 100644 index 0000000..1a5df18 Binary files /dev/null and b/test/visual/reference/0_0_body_1_phone_h.png differ diff --git a/test/visual/reference/0_0_body_2_tablet_v.png b/test/visual/reference/0_0_body_2_tablet_v.png new file mode 100644 index 0000000..b41ae45 Binary files /dev/null and b/test/visual/reference/0_0_body_2_tablet_v.png differ diff --git a/test/visual/reference/0_0_body_3_tablet_h.png b/test/visual/reference/0_0_body_3_tablet_h.png new file mode 100644 index 0000000..e1cfd36 Binary files /dev/null and b/test/visual/reference/0_0_body_3_tablet_h.png differ diff --git a/test/visual/reference/0_0_body_4_laptop.png b/test/visual/reference/0_0_body_4_laptop.png new file mode 100644 index 0000000..accf48d Binary files /dev/null and b/test/visual/reference/0_0_body_4_laptop.png differ diff --git a/test/visual/reference/0_0_body_5_desktop.png b/test/visual/reference/0_0_body_5_desktop.png new file mode 100644 index 0000000..4a646d8 Binary files /dev/null and b/test/visual/reference/0_0_body_5_desktop.png differ