Add test to NodeJS module screenshot feature

This commit is contained in:
Gaël Métais
2015-02-06 15:12:48 +01:00
parent e5f917a185
commit 9b9e65abd4
+22
View File
@@ -2,6 +2,8 @@ var chai = require('chai');
var sinon = require('sinon');
var sinonChai = require('sinon-chai');
var should = chai.should();
var path = require('path');
var fs = require('fs');
var ylt = require('../../lib/index');
chai.use(sinonChai);
@@ -99,4 +101,24 @@ describe('index.js', function() {
});
});
it('should take a screenshot', function(done) {
this.timeout(15000);
var url = 'http://localhost:8388/simple-page.html';
var screenshotPath = path.join(__dirname, '../../.tmp/indexTestScreenshot.png');
ylt(url, {screenshot: screenshotPath})
.then(function(data) {
data.params.options.should.have.a.property('screenshot').that.equals(screenshotPath);
data.should.not.have.a.property('screenshotUrl');
fs.existsSync(screenshotPath).should.equal(true);
done();
}).fail(function(err) {
done(err);
});
});
});