Skip to content

Commit

Permalink
Setup integration snapshot test
Browse files Browse the repository at this point in the history
  • Loading branch information
hanneskaeufler committed Feb 10, 2018
1 parent dbce7e6 commit bb59d45
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
*.pyc
actual.png
diff.png
/node_modules/
16 changes: 16 additions & 0 deletions integration_tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var fs = require('fs'),
PNG = require('pngjs').PNG,
pixelmatch = require('pixelmatch');

var img1 = fs.createReadStream('expected.png').pipe(new PNG()).on('parsed', doneReading),
img2 = fs.createReadStream('actual.png').pipe(new PNG()).on('parsed', doneReading),
filesRead = 0;

function doneReading() {
if (++filesRead < 2) return;
var diff = new PNG({width: img1.width, height: img1.height});

pixelmatch(img1.data, img2.data, diff.data, img1.width, img1.height, {threshold: 0.1});

diff.pack().pipe(fs.createWriteStream('diff.png'));
}
7 changes: 7 additions & 0 deletions integration_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import dash

def main():
dash.Dash().render().save('actual.png')

if __name__ == '__main__':
main()
23 changes: 23 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "e-ink-dash",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "python dash_tests.py && python integration_tests.py && node integration_tests.js && open diff.png"
},
"author": "",
"license": "ISC",
"devDependencies": {
"pixelmatch": "^4.0.2"
}
}

0 comments on commit bb59d45

Please sign in to comment.