Skip to content

Commit

Permalink
fix: move error details under stacktrace, add info to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Rashid Ksirov committed Oct 1, 2019
1 parent 043b4b7 commit e532d83
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 12 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ Plugin has following configuration:
* **path** (optional) `String` - path to directory for saving html report file; by
default html report will be saved into `gemini-report/index.html` inside current work
directory.
* **saveErrorDetails** (optional) `Boolean` – save/don't save error details to json-files (to error-details folder); `false` by default
* **saveErrorDetails** (optional) `Boolean` – save/don't save error details to json-files (to error-details folder); `false` by default.

Any plugin of hermione can add error details when throwing an error. Details can help a user to debug a problem in a test. Html-reporter saves these details to a file with name `<hash of suite path>-<browser>_<retry number>_<timestamp>.json` in the error-details folder. Below a stacktrace html-reporter adds the section `Error details` with the link `title` pointing to the json-file. A user can open it in a browser or any IDE.

How to add error details when throwing an error from a plugin:
```
const err = new Error('some error');
err.details = {title: 'description, will be used as url title', data: {} | [] | 'some additional info'};
```
* **defaultView** (optional) `String` - default view mode. Available values are:
* `all` - show all tests. Default value.
* `failed` - show only failed tests.
Expand Down
16 changes: 11 additions & 5 deletions lib/static/components/section/body/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import SwitcherRetry from '../switcher-retry';
import ControlButton from '../../controls/control-button';
import State from '../../state';
import MetaInfo from './meta-info';
import ErrorDetails from './error-details';
import Description from './description';
import * as actions from '../../../modules/actions';
import {isSuccessStatus, isErroredStatus} from '../../../../common-utils';
Expand Down Expand Up @@ -119,9 +118,15 @@ class Body extends Component {
}

_getActiveResult = () => {
if (this._activeResult) {
return this._activeResult;
}

const {result, retries} = this.props;

return retries.concat(result)[this.state.retry];
this._activeResult = retries.concat(result)[this.state.retry];

return this._activeResult;
}

_getTabs() {
Expand All @@ -146,6 +151,8 @@ class Body extends Component {

_drawTab(state, key = '', opts = {}) {
const {result: {name: browserId}, suite: {suitePath}} = this.props;
const {errorDetails} = this._getActiveResult();

opts = defaults({error: state.error}, opts);

return (
Expand All @@ -154,7 +161,7 @@ class Body extends Component {
<State
state={state} suitePath={suitePath} browserId={browserId}
acceptHandler={this.onTestAccept} toggleHandler={this.onToggleStateResult}
findSameDiffsHandler={this.onTestFindSameDiffs} {...opts}
findSameDiffsHandler={this.onTestFindSameDiffs} {...opts} errorDetails={errorDetails}
/>
</div>
</div>
Expand All @@ -168,7 +175,7 @@ class Body extends Component {
render() {
const {retries} = this.props;
const activeResult = this._getActiveResult();
const {metaInfo, suiteUrl, description, errorDetails} = activeResult;
const {metaInfo, suiteUrl, description} = activeResult;

return (
<div className="section__body">
Expand All @@ -183,7 +190,6 @@ class Body extends Component {
<MetaInfo metaInfo={metaInfo} suiteUrl={suiteUrl} getExtraMetaInfo={this.getExtraMetaInfo}/>
{description && <Description content={description}/>}
{this._getTabs()}
{errorDetails && <ErrorDetails errorDetails={errorDetails}/>}
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import React, {Component} from 'react';
import PropTypes from 'prop-types';
import ToggleOpen from '../../toggle-open';
import ToggleOpen from '../toggle-open';

export default class ErrorDetails extends Component {
static propTypes = {
Expand Down
6 changes: 3 additions & 3 deletions lib/static/components/state/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class State extends Component {

render() {
const {status, expectedImg, actualImg, diffImg, stateName, diffClusters} = this.props.state;
const {image, error} = this.props;
const {image, error, errorDetails} = this.props;
let elem = null;

if (!this.state.opened) {
Expand All @@ -132,12 +132,12 @@ class State extends Component {
}

if (isErroredStatus(status)) {
elem = <StateError image={Boolean(image)} actualImg={actualImg} error={error}/>;
elem = <StateError image={Boolean(image)} actualImg={actualImg} error={error} errorDetails={errorDetails}/>;
} else if (isSuccessStatus(status) || isUpdatedStatus(status) || (isIdleStatus(status) && get(expectedImg, 'path'))) {
elem = <StateSuccess status={status} expectedImg={expectedImg} />;
} else if (isFailStatus(status)) {
elem = error
? <StateError image={Boolean(image)} actualImg={actualImg} error={error}/>
? <StateError image={Boolean(image)} actualImg={actualImg} error={error} errorDetails={errorDetails}/>
: <StateFail expectedImg={expectedImg} actualImg={actualImg} diffImg={diffImg} diffClusters={diffClusters}/>;
}

Expand Down
4 changes: 3 additions & 1 deletion lib/static/components/state/state-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {map} from 'lodash';
import Screenshot from './screenshot';
import ToggleOpen from '../toggle-open';
import {isNoRefImageError} from '../../modules/utils';
import ErrorDetails from './error-details';

export default class StateError extends Component {
static propTypes = {
Expand All @@ -15,11 +16,12 @@ export default class StateError extends Component {
};

render() {
const {image, error, actualImg} = this.props;
const {image, error, errorDetails, actualImg} = this.props;

return (
<div className="image-box__image image-box__image_single">
<div className="error">{errorToElements(error)}</div>
{errorDetails && <ErrorDetails errorDetails={errorDetails}/>}
{this._drawImage(image, actualImg)}
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion lib/test-adapter/hermione-test-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ module.exports = class HermioneTestResultAdapter extends TestAdapter {
return;
}

const detailsFilePath = `${path.resolve(reportPath)}/${this.errorDetails.filePath}`;
const detailsFilePath = path.resolve(reportPath, this.errorDetails.filePath);
const detailsData = _.isObject(this.errorDetails.data)
? JSON.stringify(this.errorDetails.data, null, 2)
: this.errorDetails.data;
Expand Down

0 comments on commit e532d83

Please sign in to comment.