chore: simplify expect zone wrapper (#27145)
This commit is contained in:
parent
40e8445b82
commit
6b36a50969
|
|
@ -282,31 +282,17 @@ class ExpectMetaInfoProxyHandler implements ProxyHandler<any> {
|
||||||
step?.complete({});
|
step?.complete({});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Process the async matchers separately to preserve the zones in the stacks.
|
const expectZone: ExpectZone = { title, wallTime };
|
||||||
if (this._info.isPoll || (matcherName in customAsyncMatchers && matcherName !== 'toPass')) {
|
// We assume that the matcher will read the current expect timeout the first thing.
|
||||||
return (async () => {
|
setCurrentExpectConfigureTimeout(this._info.timeout);
|
||||||
try {
|
try {
|
||||||
const expectZone: ExpectZone = { title, wallTime };
|
const result = zones.run<ExpectZone, any>('expectZone', expectZone, () => matcher.call(target, ...args));
|
||||||
await zones.run<ExpectZone, any>('expectZone', expectZone, async () => {
|
if (result instanceof Promise)
|
||||||
// We assume that the matcher will read the current expect timeout the first thing.
|
return result.then(finalizer).catch(reportStepError);
|
||||||
setCurrentExpectConfigureTimeout(this._info.timeout);
|
finalizer();
|
||||||
await matcher.call(target, ...args);
|
return result;
|
||||||
});
|
} catch (e) {
|
||||||
finalizer();
|
reportStepError(e);
|
||||||
} catch (e) {
|
|
||||||
reportStepError(e);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
const result = matcher.call(target, ...args);
|
|
||||||
if (result instanceof Promise)
|
|
||||||
return result.then(finalizer).catch(reportStepError);
|
|
||||||
finalizer();
|
|
||||||
return result;
|
|
||||||
} catch (e) {
|
|
||||||
reportStepError(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue