diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3e6a2de71..bdea5b70b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,16 @@
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.
+
+## [2.20.3](https://github.com/gemini-testing/html-reporter/compare/v2.20.2...v2.20.3) (2018-07-12)
+
+
+### Bug Fixes
+
+* broken images for tests with no reference image ([99e5869](https://github.com/gemini-testing/html-reporter/commit/99e5869))
+
+
+
## [2.20.2](https://github.com/gemini-testing/html-reporter/compare/v2.20.1...v2.20.2) (2018-07-10)
diff --git a/lib/report-builder-factory/report-builder.js b/lib/report-builder-factory/report-builder.js
index d5697dc22..11151003f 100644
--- a/lib/report-builder-factory/report-builder.js
+++ b/lib/report-builder-factory/report-builder.js
@@ -5,7 +5,7 @@ const Promise = require('bluebird');
const _ = require('lodash');
const fs = require('fs-extra');
const {IDLE, RUNNING, SUCCESS, FAIL, ERROR, SKIPPED, UPDATED} = require('../constants/test-statuses');
-const {logger, getPathsFor} = require('../server-utils');
+const {logger, getPathsFor, hasImage} = require('../server-utils');
const {setStatusForBranch, hasFails} = require('../static/modules/utils');
const NO_STATE = 'NO_STATE';
@@ -83,7 +83,6 @@ module.exports = class ReportBuilder {
_addErrorResult(formattedResult) {
return this._addTestResult(formattedResult, {
status: ERROR,
- image: !!formattedResult.getImagesInfo(ERROR).length || !!formattedResult.currentPath || !!formattedResult.screenshot,
reason: formattedResult.error
});
}
@@ -125,6 +124,7 @@ module.exports = class ReportBuilder {
if (existing === -1) {
formattedResult.attempt = testResult.attempt;
+ formattedResult.image = hasImage(formattedResult);
extendTestWithImagePaths(testResult, formattedResult);
node.browsers.push({name: browserId, result: testResult, retries: []});
setStatusForBranch(this._tree, node.suitePath, testResult.status);
@@ -148,6 +148,7 @@ module.exports = class ReportBuilder {
}
formattedResult.attempt = testResult.attempt;
+ formattedResult.image = hasImage(formattedResult);
const {imagesInfo} = stateInBrowser.result;
stateInBrowser.result = extendTestWithImagePaths(testResult, formattedResult, imagesInfo);
diff --git a/lib/server-utils.js b/lib/server-utils.js
index dc106bbb2..92c32f8e4 100644
--- a/lib/server-utils.js
+++ b/lib/server-utils.js
@@ -96,11 +96,16 @@ function getPathsFor(status, formattedResult, stateName) {
return {};
}
+function hasImage(formattedResult) {
+ return !!formattedResult.getImagesInfo(ERROR).length || !!formattedResult.currentPath || !!formattedResult.screenshot;
+}
+
module.exports = {
getReferencePath,
getCurrentPath,
getDiffPath,
getPathsFor,
+ hasImage,
getReferenceAbsolutePath,
getCurrentAbsolutePath,
diff --git a/package-lock.json b/package-lock.json
index 5aa95d213..b1daa728e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "html-reporter",
- "version": "2.20.2",
+ "version": "2.20.3",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
diff --git a/package.json b/package.json
index 3ea5a3aab..b9e7c29fd 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "html-reporter",
- "version": "2.20.2",
+ "version": "2.20.3",
"description": "Plugin for gemini and hermione which is intended to aggregate the results of tests running into html report",
"scripts": {
"lint": "eslint .",
diff --git a/test/lib/report-builder-factory/report-builder.js b/test/lib/report-builder-factory/report-builder.js
index 15a96d91b..48735bfba 100644
--- a/test/lib/report-builder-factory/report-builder.js
+++ b/test/lib/report-builder-factory/report-builder.js
@@ -3,11 +3,12 @@
const fs = require('fs-extra');
const _ = require('lodash');
const {logger} = require('../../../lib/server-utils');
-const ReportBuilder = require('../../../lib/report-builder-factory/report-builder');
+const proxyquire = require('proxyquire');
const {SUCCESS, FAIL, ERROR, SKIPPED, IDLE, UPDATED} = require('../../../lib/constants/test-statuses');
describe('ReportBuilder', () => {
const sandbox = sinon.sandbox.create();
+ let hasImage, ReportBuilder;
const mkReportBuilder_ = ({toolConfig, pluginConfig} = {}) => {
toolConfig = _.defaults(toolConfig || {}, {getAbsoluteUrl: _.noop});
@@ -44,6 +45,13 @@ describe('ReportBuilder', () => {
sandbox.stub(fs, 'mkdirsSync');
sandbox.stub(fs, 'writeFileAsync').resolves();
sandbox.stub(fs, 'writeFileSync');
+
+ hasImage = sandbox.stub().returns(true);
+ ReportBuilder = proxyquire('../../../lib/report-builder-factory/report-builder', {
+ '../server-utils': {
+ hasImage
+ }
+ });
});
afterEach(() => sandbox.restore());
@@ -165,6 +173,19 @@ describe('ReportBuilder', () => {
});
});
+ it('should get correct test attempt while checking for image exists', () => {
+ const reportBuilder = mkReportBuilder_();
+ const testResult = stubTest_();
+
+ reportBuilder.addError(testResult);
+ const firstCallAttempt = hasImage.firstCall.args[0].attempt;
+ reportBuilder.addError(testResult);
+ const secondCallAttempt = hasImage.secondCall.args[0].attempt;
+
+ assert.equal(firstCallAttempt, 0);
+ assert.equal(secondCallAttempt, 1);
+ });
+
it('should add base host to result with value from plugin parameter "baseHost"', () => {
const reportBuilder = mkReportBuilder_({pluginConfig: {baseHost: 'some-host'}});