diff --git a/test/index.js b/test/index.js index e4ae8af3..8477f103 100644 --- a/test/index.js +++ b/test/index.js @@ -41,3 +41,12 @@ test('show download path missing', function (t) { .then(() => setup.endTest(app, t), (err) => setup.endTest(app, t, err || 'error')) }) + +// TODO: +// require('./test-torrent-list') +// require('./test-add-torrent') +// require('./test-create-torrent') +// require('./test-prefs') +// require('./test-video') +// require('./test-audio') +// require('./test-cast') diff --git a/test/setup.js b/test/setup.js index e3da57f6..7bcd4e33 100644 --- a/test/setup.js +++ b/test/setup.js @@ -59,7 +59,8 @@ function endTest (app, t, err) { // If we already have a reference under test/screenshots, assert that they're the same // Otherwise, create the reference screenshot: test/screenshots//.png function screenshotCreateOrCompare (app, t, name) { - const ssPath = path.join(__dirname, 'screenshots', process.platform, name + '.png') + const ssDir = path.join(__dirname, 'screenshots', process.platform) + const ssPath = path.join(ssDir, name + '.png') fs.ensureFileSync(ssPath) const ssBuf = fs.readFileSync(ssPath) return app.browserWindow.capturePage().then(function (buffer) { @@ -67,8 +68,13 @@ function screenshotCreateOrCompare (app, t, name) { console.log('Saving screenshot ' + ssPath) fs.writeFileSync(ssPath, buffer) } else { - t.ok(Buffer.compare(buffer, ssBuf) === 0, 'screenshot ' + name) - return Promise.resolve() + const match = Buffer.compare(buffer, ssBuf) === 0 + t.ok(match, 'screenshot comparison ' + name) + if (!match) { + const ssFailedPath = path.join(ssDir, name + '-failed.png') + console.log('Saving screenshot, failed comparison: ' + ssFailedPath) + fs.writeFileSync(ssFailedPath, buffer) + } } }) }