Skip to content

Commit 4584b67

Browse files
authored
fix: display a human-readable error message when report is completely empty (#585)
1 parent ed0a2c3 commit 4584b67

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

lib/static/components/controls/browser-list/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const BrowserList = ({available, onChange, selected: selectedProp}) => {
3030
});
3131
});
3232
if (!hasNestedOptions) {
33-
return groups[DEFAULT_GROUP];
33+
return groups[DEFAULT_GROUP] ?? [];
3434
} else {
3535
const optionsList = [];
3636
Object.keys(groups).forEach((name) => {

lib/static/components/suites.jsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,16 @@ function Suites(props) {
112112

113113
const {visibleRootSuiteIds} = props;
114114

115-
if (isEmpty(visibleRootSuiteIds)) {
115+
if (props.isReportEmpty) {
116+
return <div className="sections sections_type_empty">
117+
There are no tests to show. Please, try the following:
118+
<ul>
119+
<li>Check if your project contains any tests;</li>
120+
<li>Check if the tool you are using is configured correctly and is able to find your tests;</li>
121+
<li>Check if some critical error has occurred in logs that prevented HTML reporter from collecting any results.</li>
122+
</ul>
123+
</div>;
124+
} else if (isEmpty(visibleRootSuiteIds)) {
116125
const selectedFiltersMsgs = _getSelectedFiltersInfo();
117126

118127
return <div className="sections sections_type_empty">
@@ -159,6 +168,7 @@ Suites.propTypes = {
159168
actions: PropTypes.object.isRequired,
160169
testNameFilter: PropTypes.string,
161170
strictMatchFilter: PropTypes.bool,
171+
isReportEmpty: PropTypes.bool,
162172
filteredBrowsers: PropTypes.arrayOf(PropTypes.shape({
163173
id: PropTypes.string,
164174
versions: PropTypes.arrayOf(PropTypes.string)
@@ -171,7 +181,8 @@ export default connect(
171181
viewMode: state.view.viewMode,
172182
filteredBrowsers: state.view.filteredBrowsers,
173183
testNameFilter: state.view.testNameFilter,
174-
strictMatchFilter: state.view.strictMatchFilter
184+
strictMatchFilter: state.view.strictMatchFilter,
185+
isReportEmpty: isEmpty(state.tree.browsers.byId)
175186
}),
176187
(dispatch) => ({actions: bindActionCreators(actions, dispatch)})
177188
)(Suites);

test/unit/lib/static/components/suites.jsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,28 @@ describe('<Suites/>', () => {
4848
sandbox.restore();
4949
});
5050

51-
it('should not render List component if there are no visible root suite ids', () => {
51+
it('should render hint when the report is completely empty', () => {
5252
getVisibleRootSuiteIds.returns([]);
5353

5454
const component = mkSuitesComponent();
5555

56-
expect(component.getByText('There are no tests', {exact: false})).to.exist;
56+
expect(component.getByText('There are no tests to show. Please, try the following', {exact: false})).to.exist;
57+
});
58+
59+
it('should render hint when no tests matched filters', () => {
60+
getVisibleRootSuiteIds.returns([]);
61+
62+
const component = mkSuitesComponent({
63+
tree: {
64+
browsers: {
65+
byId: {
66+
'bro-1': {}
67+
}
68+
}
69+
}
70+
});
71+
72+
expect(component.getByText('There are no tests that match to selected filters', {exact: false})).to.exist;
5773
});
5874

5975
it('should render few section common components', async () => {
@@ -73,6 +89,11 @@ describe('<Suites/>', () => {
7389
'suite-id-1': {shouldBeShown: true, shouldBeOpened: false},
7490
'suite-id-2': {shouldBeShown: true, shouldBeOpened: false}
7591
}
92+
},
93+
browsers: {
94+
byId: {
95+
'bro-1': {}
96+
}
7697
}
7798
}
7899
});

0 commit comments

Comments
 (0)