YMFE/yapi · warning
还没有生成报告
Error message
还没有生成报告
What it means
openReport in InterfaceColContent.js shows an Ant Design warning when no test report exists for the given case id in the component's in-memory this.reports map. Reports are only populated after a test run completes in the current session, so opening one prematurely warns 'report not generated yet'.
Source
Thrown at client/containers/Project/Interface/InterfaceCol/InterfaceColContent.js:508
}
// 测试用例环境面板折叠
changeCollapseClose = key => {
if (key) {
this.setState({
collapseKey: key
});
} else {
this.setState({
collapseKey: '1',
currColEnvObj: {}
});
}
};
openReport = id => {
if (!this.reports[id]) {
return message.warn('还没有生成报告');
}
this.setState({ visible: true, curCaseid: id });
};
openAdv = id => {
let findCase = _.find(this.props.currCaseList, item => item.id === id);
this.setState({
enableScript: findCase.enable_script,
curScript: findCase.test_script,
advVisible: true,
curCaseid: id
});
};
handleScriptChange = d => {
this.setState({ curScript: d.text });
};View on GitHub (pinned to 59bade3a8a)
Solutions
- Run the test case/col first so a report is generated, then open the report
- Persist reports (server-side or localStorage) if they must survive page refreshes
- Check the test-run request for failures that prevented the report from being stored in this.reports
- Catch/verify this.reports[id] exists before navigating to the report view
Example fix
// before
openReport = id => {
this.setState({ visible: true, curCaseid: id });
};
// after
openReport = id => {
if (!this.reports[id]) {
return message.warn('还没有生成报告,请先运行测试');
}
this.setState({ visible: true, curCaseid: id });
}; Defensive patterns
Strategy: type-guard
Validate before calling
const openReportIfReady = id => {
if (this.reports && this.reports[id]) this.openReport(id);
else message.warn('Run the test first to generate a report');
}; Type guard
function hasReport(reports, id){ return Boolean(reports) && Object.prototype.hasOwnProperty.call(reports, id) && !!reports[id]; } Try / catch
// component-level guard before opening if (!hasReport(this.reports, id)) return; // avoid setState on missing report
Prevention
- Disable the 'open report' button until a run has completed for the case
- Persist reports to the server/localStorage so they survive page refreshes
- Handle failed test runs so reports map entries are not silently skipped
- Write integration tests covering open-before-run flows
When it happens
Trigger: Clicking the 'open report' action for a case before running it, after a page refresh (this.reports is reset, not persisted), or for a case whose run failed before producing a report.
Common situations: User expects reports to persist across reloads; automated script triggers openReport without first invoking the test run; report generation failed server-side so this.reports[id] was never set.
AI-assisted analysis of YMFE/yapi@59bade3a8a (2026-08-29).
Data as JSON: /api/errors/89c9a5ed66b9c3c2.
Report an issue: GitHub.