Flaky Explorer API 测试在 CI 上偶尔对不相关的 PR 失败
作者: cdamus创建于 2026年9月12日更新于 2026年9月13日
标签citest
问题描述:
在 examples/api-tests/src/explorer-open-close.spec.js 中的 API 测试 Explorer and Editor - open and close 在 CI 上出现了问题。它在间歇性出现失败,如下所示:
1) Explorer and Editor - open and close
Open/Close explorer and editor - ordering: 0, iteration #0:
AssertionError: Explorer widget should not exist:
expected ViewContainer{ _flags: 10, …(42) } to equal undefined
at closeExplorer (examples/api-tests/src/explorer-open-close.spec.js:121:16)
at async Context.<anonymous> (examples/api-tests/src/explorer-open-close.spec.js:69:13)失败的断言位于测试的 closeExplorer() 帮助函数中:
async function closeExplorer() {
await navigatorContribution.closeView();
assert.isUndefined(await shell.revealWidget(EXPLORER_VIEW_CONTAINER_ID), 'Explorer widget should not exist');
}ApplicationShell.revealWidget 只在 id 仍然存在于 shell 的 widget 跟踪器(toTrackedStack、packages/core/src/browser/shell/application-shell.ts:1313)时才解析为一个 widget。因此,断言失败意味着在 closeView() 解析时,Explorer ViewContainer 仍然被跟踪,尽管 ApplicationShell.closeWidget 等待 waitForClosed(current) 和 this.pendingUpdates(application-shell.ts:1757)。
这表明 widget 关闭/脱离与从 shell 的 tracker 中移除之间存在竞争。测试在中间状态下观察了 tracker。有两件事情值得决定:
closeWidget是否应保证 widget 一旦其 promise 解析,就不再被跟踪(产品 bug),或者- 测试是否不应使用
revealWidget,一个 * 修改 * 的显示操作,作为存在性检查(测试 bug)
请注意,revealWidget 并非无副作用:如果 widget 仍然被跟踪,则调用将其再次显示,因此断言可能会扰乱它检查的状态本身。
内容来源: eclipse-theia/theia