Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: gemini-testing/gemini
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.15.0
Choose a base ref
...
head repository: gemini-testing/gemini
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v4.16.0
Choose a head ref
  • 7 commits
  • 6 files changed
  • 2 contributors

Commits on Dec 22, 2016

  1. Copy the full SHA
    73a26ed View commit details
  2. Merge pull request #683 from up73k/master

    feat: Add extended WebDriver error data in output
    up73k authored Dec 22, 2016
    Copy the full SHA
    fefd44f View commit details
  3. Copy the full SHA
    feb72bc View commit details
  4. Merge pull request #700 from gemini-testing/fix/update

    fix: 'update' command
    eGavr authored Dec 22, 2016
    Copy the full SHA
    0b143cb View commit details

Commits on Dec 23, 2016

  1. Copy the full SHA
    86a8466 View commit details
  2. Merge pull request #703 from gemini-testing/fix/log-path-to-html-report

    fix: log a path to an HTML report after tests finish
    eGavr authored Dec 23, 2016
    Copy the full SHA
    34dc1bd View commit details
  3. chore(release): 4.16.0

    eGavr committed Dec 23, 2016
    Copy the full SHA
    d2232fb View commit details
Showing with 127 additions and 11 deletions.
  1. +16 βˆ’0 CHANGELOG.md
  2. +19 βˆ’0 lib/browser/new-browser.js
  3. +14 βˆ’9 lib/cli/index.js
  4. +1 βˆ’1 lib/reporters/html/index.js
  5. +2 βˆ’1 package.json
  6. +75 βˆ’0 test/unit/browser/new-browser.js
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,22 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

<a name="4.16.0"></a>
# [4.16.0](https://github.com/gemini-testing/gemini/compare/v4.15.0...v4.16.0) (2016-12-23)


### Bug Fixes

* log a path to an HTML report after tests finish ([86a8466](https://github.com/gemini-testing/gemini/commit/86a8466))
* set default reporter for command 'update' ([feb72bc](https://github.com/gemini-testing/gemini/commit/feb72bc))


### Features

* Add extended WebDriver error data in output ([73a26ed](https://github.com/gemini-testing/gemini/commit/73a26ed))



<a name="4.15.0"></a>
# [4.15.0](https://github.com/gemini-testing/gemini/compare/v4.14.4...v4.15.0) (2016-12-21)

19 changes: 19 additions & 0 deletions lib/browser/new-browser.js
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ const debug = require('debug');
const chalk = require('chalk');
const _ = require('lodash');
const Promise = require('bluebird');
const striptags = require('striptags');

const Browser = require('./browser');
const ClientBridge = require('./client-bridge');
@@ -116,6 +117,10 @@ module.exports = class NewBrowser extends Browser {

const error = new GeminiError(`Cannot launch browser ${this.id}:\n${e.message}.`);

if (e.data) {
error.message += '\nReason: ' + this._parseHtmlBody(e.data);
}

error.browserId = this.id;
error.sessionId = this.sessionId;

@@ -124,6 +129,20 @@ module.exports = class NewBrowser extends Browser {
});
}

_parseHtmlBody(html) {
const body = html.match(/<body[\s\S]*<\/body>/i);

if (!body) {
return html;
}

const rawText = striptags(body[0]);

return rawText
? (rawText).replace(/\s+/g, ' ').trim()
: html;
}

_setSessionTimeout(timeout) {
if (_.isNull(timeout)) {
timeout = this.config.httpTimeout;
23 changes: 14 additions & 9 deletions lib/cli/index.js
Original file line number Diff line number Diff line change
@@ -97,17 +97,9 @@ function runGemini(method, paths, options) {
return gemini;
})
.then((gemini) => {
function parseReporterOptions(options) {
return options.reporter.map(function(name) {
return {
name,
path: options[`${name}ReporterPath`]
};
});
}
return gemini[method](paths, {
sets: options.set,
reporters: parseReporterOptions(options) || [{name: 'flat'}],
reporters: parseReporterOptions(options),
grep: program.grep,
browsers: program.browser,
diff: options.diff,
@@ -124,6 +116,19 @@ function runGemini(method, paths, options) {
.then(exit);
}

function parseReporterOptions(options) {
if (!options.reporter) {
return [{name: 'flat'}];
}

return options.reporter.map(function(name) {
return {
name,
path: options[`${name}ReporterPath`]
};
});
}

function exit(code) {
process.on('exit', () => process.exit(exitCode || code));
}
2 changes: 1 addition & 1 deletion lib/reporters/html/index.js
Original file line number Diff line number Diff line change
@@ -126,7 +126,7 @@ module.exports = function htmlReporter(runner, reportPath) {
const generateReportPromise = Promise.all([prepareViewData(runner), prepareImages(runner)])
.spread(view.createHtml)
.then((html) => view.save(html, reportPath))
.then(logPathToHtmlReport(reportPath))
.then(() => logPathToHtmlReport(reportPath))
.catch(logError);

runner.on(Events.END_RUNNER, () => generateReportPromise.thenReturn());
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gemini",
"version": "4.15.0",
"version": "4.16.0",
"description": "UI Screenshot testing utility",
"engines": {
"node": ">= 4.0.0"
@@ -40,6 +40,7 @@
"resolve": "^1.1.0",
"sizzle": "^2.2.0",
"source-map": "^0.5.3",
"striptags": "^2.1.1",
"temp": "~0.8.0",
"uglify-js": "^2.7.3",
"uglifyify": "^3.0.1",
75 changes: 75 additions & 0 deletions test/unit/browser/new-browser.js
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ const Camera = require('lib/browser/camera');
const ClientBridge = require('lib/browser/client-bridge');
const Calibrator = require('lib/calibrator');
const WdErrors = require('lib/constants/wd-errors');
const GeminiError = require('lib/errors/gemini-error');

const makeBrowser = require('../../util').makeBrowser;

@@ -203,6 +204,80 @@ describe('browser/new-browser', () => {
return assert.isRejected(launchBrowser());
});
});

describe('catch error on wd init', () => {
it('should fail if wd init fails', () => {
wd.init.returns(Promise.reject(new Error('o.O')));

return assert.isRejected(launchBrowser());
});

it('should fail with GeminiError instance', () => {
wd.init.returns(Promise.reject({message: 'defaultError'}));

return assert.isRejected(launchBrowser(), GeminiError);
});

it('should fail with the error message by default', () => {
wd.init.returns(Promise.reject({message: 'error text'}));

return launchBrowser()
.catch((e) => assert.include(e.message, 'error text'));
});

it('should extend error message with error data if it exists', () => {
wd.init.returns(Promise.reject({data: 'error text'}));

return launchBrowser()
.catch((e) => assert.include(e.message, 'error text'));
});

it('should not add to the message fail reason if error data does not exists', () => {
wd.init.returns(Promise.reject({message: 'defaultError'}));

return launchBrowser()
.catch((e) => assert.notInclude(e.message, 'Reason'));
});

it('should cut all tags from error', () => {
wd.init.returns(Promise.reject({data: '<title></title><body><h1>Error</h1> text</body>'}));

return launchBrowser()
.catch((e) => {
assert.notInclude(e.message, '<title>');
assert.notInclude(e.message, '<body>');
assert.notInclude(e.message, '<h1>');
});
});

it('should skip text from all tags except body', () => {
wd.init.returns(Promise.reject({data: '<title>4xx</title><body>Error</body>'}));

return launchBrowser()
.catch((e) => assert.notInclude(e.message, '4xx'));
});

it('should not skip text from internal tags in body tag', () => {
wd.init.returns(Promise.reject({data: '<body><h1>Error</h1> text</body>'}));

return launchBrowser()
.catch((e) => assert.include(e.message, 'Error text'));
});

it('should replace newlines to spaces', () => {
wd.init.returns(Promise.reject({data: '<body>Error\ntext</body>'}));

return launchBrowser()
.catch((e) => assert.include(e.message, 'Error text'));
});

it('should fail with full html if <body> tag is empty', () => {
wd.init.returns(Promise.reject({data: '<html><body></body></html>'}));

return launchBrowser()
.catch((e) => assert.include(e.message, '<html><body></body></html>'));
});
});
});

describe('URL opening', () => {