From 9b9e65abd45d2a014bdd13981f3e4ff7990fe856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Fri, 6 Feb 2015 15:12:48 +0100 Subject: [PATCH] Add test to NodeJS module screenshot feature --- test/core/indexTest.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/core/indexTest.js b/test/core/indexTest.js index 2801b85..93b0824 100644 --- a/test/core/indexTest.js +++ b/test/core/indexTest.js @@ -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); + }); + }); + }); \ No newline at end of file