[Expressions] Fix flaky test checking execution duration (#110338)

This commit is contained in:
Michael Dokolin 2021-08-31 17:59:51 +02:00 committed by GitHub
parent 77b8e25b98
commit 475eaf2c76
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -763,13 +763,15 @@ describe('Execution', () => {
});
test('saves duration it took to execute each function', async () => {
const startTime = Date.now();
const execution = createExecution('add val=1 | add val=2 | add val=3', {}, true);
execution.start(-1);
await execution.result.toPromise();
const duration = Date.now() - startTime;
for (const node of execution.state.get().ast.chain) {
expect(typeof node.debug?.duration).toBe('number');
expect(node.debug?.duration).toBeLessThan(100);
expect(node.debug?.duration).toBeLessThanOrEqual(duration);
expect(node.debug?.duration).toBeGreaterThanOrEqual(0);
}
});