Skip to content

Commit b816b2e

Browse files
author
Albin Mattsson
committed
Add Travis configuration
This closes #108
1 parent 67fa3f8 commit b816b2e

File tree

6 files changed

+40
-9
lines changed

6 files changed

+40
-9
lines changed

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
language: node_js
2+
osx_image: xcode7.3
3+
os:
4+
- osx
5+
node_js:
6+
- 6
7+
script:
8+
- defaults write NSGlobalDomain AppleShowAllExtensions -bool true
9+
- killall Finder
10+
- npm test

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
},
3535
"devDependencies": {
3636
"capture-window": "^0.1.3",
37+
"imgur": "^0.1.7",
3738
"looks-same": "^2.1.0",
3839
"mocha": "^2.2.5",
3940
"standard": "^7.0.1"

test/api.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ var assert = require('assert')
1111

1212
var STEPS = 20
1313

14+
var CI_PREFIX = process.env.TRAVIS ? 'travis-' : ''
15+
1416
function runAppdmg (opts, verify, cb) {
1517
var progressCalled = 0
1618
var ee = appdmg(opts)
@@ -56,7 +58,7 @@ describe('api', function () {
5658
var verify = {
5759
format: 'UDZO',
5860
title: 'Test Title',
59-
visually: 'accepted-1.png'
61+
visually: CI_PREFIX + 'accepted-1.png'
6062
}
6163

6264
runAppdmg(opts, verify, done)
@@ -73,7 +75,7 @@ describe('api', function () {
7375
var verify = {
7476
format: 'UDZO',
7577
title: 'Test Title',
76-
visually: 'accepted-1.png'
78+
visually: CI_PREFIX + 'accepted-1.png'
7779
}
7880

7981
runAppdmg(opts, verify, done)
@@ -100,7 +102,7 @@ describe('api', function () {
100102
var verify = {
101103
format: 'UDZO',
102104
title: 'Test Title',
103-
visually: 'accepted-1.png'
105+
visually: CI_PREFIX + 'accepted-1.png'
104106
}
105107

106108
runAppdmg(opts, verify, done)
@@ -128,7 +130,7 @@ describe('api', function () {
128130
var verify = {
129131
format: 'UDRO',
130132
title: 'Test Title',
131-
visually: 'accepted-1.png'
133+
visually: CI_PREFIX + 'accepted-1.png'
132134
}
133135

134136
runAppdmg(opts, verify, done)

test/lib/visually-verify-image.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var looksSame = require('looks-same')
44
var spawnSync = require('child_process').spawnSync
55
var captureWindow = require('capture-window')
66
var sizeOf = require('image-size')
7+
var imgur = require('imgur')
78

89
var hdiutil = require('../../lib/hdiutil')
910

@@ -63,11 +64,28 @@ function captureAndSaveDiff (title, expectedPath, cb) {
6364
looksSame.createDiff(opts, function (err, data) {
6465
if (err) return cb(err)
6566

66-
temp.writeFile(data, function (err, diffPath) {
67-
if (err) return cb(err)
68-
69-
cb(null, { diff: diffPath, actual: pngPath })
70-
})
67+
if (process.env.CI) {
68+
imgur.uploadFile(pngPath)
69+
.then(function (json) {
70+
const pngUrl = json.data.link
71+
imgur.uploadBase64(data.toString('base64'))
72+
.then(function (json) {
73+
setImmediate(cb, null, { diff: json.data.link, actual: pngUrl })
74+
})
75+
.catch(function (err) {
76+
setImmediate(cb, err)
77+
})
78+
})
79+
.catch(function (err) {
80+
setImmediate(cb, err)
81+
})
82+
} else {
83+
temp.writeFile(data, function (err, diffPath) {
84+
if (err) return cb(err)
85+
86+
cb(null, { diff: diffPath, actual: pngPath })
87+
})
88+
}
7189
})
7290
})
7391
}

test/travis-accepted-1.png

66.4 KB
Loading

test/travis-accepted-2.png

67.6 KB
Loading

0 commit comments

Comments
 (0)