test(sdk-metrics): fix multiple problematic assertRejects() calls (#5611)
This commit is contained in:
parent
37fe1e495b
commit
c89cb38d0f
|
@ -25,6 +25,8 @@ For notes on migrating to 2.x / 0.200.x see [the upgrade guide](doc/upgrade-to-2
|
|||
|
||||
### :house: Internal
|
||||
|
||||
* test(sdk-metrics): fix multiple problematic assertRejects() calls [#5611](https://github.com/open-telemetry/opentelemetry-js/pull/5611) @cjihrig
|
||||
|
||||
## 2.0.0
|
||||
|
||||
### Summary
|
||||
|
|
|
@ -119,7 +119,7 @@ describe('MetricReader', () => {
|
|||
reader.setMetricProducer(new TestMetricProducer());
|
||||
|
||||
await reader.shutdown();
|
||||
assertRejects(reader.collect(), /MetricReader is shutdown/);
|
||||
await assertRejects(reader.collect(), /MetricReader is shutdown/);
|
||||
});
|
||||
|
||||
it('should call MetricProducer.collect with timeout', async () => {
|
||||
|
|
|
@ -32,11 +32,16 @@ describe('utils', () => {
|
|||
|
||||
describe('callWithTimeout', () => {
|
||||
it('should reject if given promise not settled before timeout', async () => {
|
||||
sinon.useFakeTimers();
|
||||
const clock = sinon.useFakeTimers();
|
||||
const promise = new Promise(() => {
|
||||
/** promise never settles */
|
||||
});
|
||||
assertRejects(callWithTimeout(promise, 100), TimeoutError);
|
||||
const assertion = assertRejects(
|
||||
callWithTimeout(promise, 100),
|
||||
TimeoutError
|
||||
);
|
||||
clock.tick(101);
|
||||
await assertion;
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue