Skip to content

Commit

Permalink
feat: remove screenshotOnReject option (can be set from hermione)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitriy-kiselyov committed Feb 16, 2018
1 parent c3fe42f commit aff3d84
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 51 deletions.
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ directory.
* `all` - show all tests. Default value.
* `failed` - show only failed tests.
* **baseHost** (optional) - `String` - it changes original host for view in the browser; by default original host does not change
* **screenshotOnReject** (optional, only for hermione) - attaches a screenshot of a
current page on test fail. Can be boolean or object with httpTimeout option. If
`screenshotOnReject` is set as `true`, then will be used common `httpTimeout` value. `true` by default. See example of usage [here](#hermione-usage).

Also there is ability to override plugin parameters by CLI options or environment variables
(see [configparser](https://github.com/gemini-testing/configparser)).
Expand Down Expand Up @@ -70,10 +67,7 @@ module.exports = {
enabled: true,
path: 'my/hermione-reports',
defaultView: 'all',
baseHost: 'test.com',
screenshotOnReject: {
httpTimeout: 10000
}
baseHost: 'test.com'
}
}
},
Expand Down
7 changes: 1 addition & 6 deletions hermione.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,8 @@ function saveScreenshot(imageData, destPath) {
.then(() => fs.writeFileAsync(destPath, new Buffer(imageData, 'base64'), 'base64'));
}

function prepareData(hermione, pluginConfig) {
function prepareData(hermione) {
return new Promise((resolve) => {
hermione.config.getBrowserIds().forEach((id) => {
const browserConfig = hermione.config.forBrowser(id);
browserConfig.screenshotOnReject = pluginConfig.screenshotOnReject;
});

hermione.on(hermione.events.TEST_PENDING, (testResult) => reportBuilder.addSkipped(testResult));

hermione.on(hermione.events.TEST_PASS, (testResult) => reportBuilder.addSuccess(testResult));
Expand Down
10 changes: 0 additions & 10 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ const getParser = () => {
}
}
}),
screenshotOnReject: option({
defaultValue: true,
parseEnv: JSON.parse,
parseCli: JSON.parse,
validate: (v) => {
if (!_.isBoolean(v) && !_.isPlainObject(v)) {
throw new Error(`"screenshotOnReject" option must be boolean or plain object, but got ${typeof v}`);
}
}
}),
path: option({
defaultValue: 'html-report',
validate: isString('path')
Expand Down
28 changes: 0 additions & 28 deletions test/hermione.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,32 +183,4 @@ describe('Hermione Reporter', () => {
assert.calledWith(utils.saveDiff, sinon.match.instanceOf(HermioneTestAdapter), '/absolute/report');
});
});

describe('screenshotOnReject', () => {
const eventsMap = {retry: events.RETRY, fail: events.TEST_FAIL};

_.forEach(eventsMap, (value, key) => {
it(`should save screenshot from error if error does not contain image in case of ${key}`, () => {
utils.getCurrentAbsolutePath.returns('/absolute/path');

initReporter_();

hermione.emit(value, {err: {screenshot: 'some-buffer'}});
const buffer = new Buffer('some-buffer', 'base64');

return hermione.emitAndWait(events.RUNNER_END).then(() => {
assert.calledOnceWith(fs.writeFileAsync, '/absolute/path', buffer, 'base64');
});
});

it(`should warn if error does not contain screenshot in case of ${key}`, () => {
initReporter_();
hermione.emit(value, mkStubResult_());

return hermione.emitAndWait(events.RUNNER_END).then(() => {
assert.calledOnceWith(utils.logger.warn, 'Cannot save screenshot on reject');
});
});
});
});
});

0 comments on commit aff3d84

Please sign in to comment.