diff --git a/packages/opentelemetry-scope-async-hooks/test/asynchooks/AsyncHooksScopeManager.test.ts b/packages/opentelemetry-scope-async-hooks/test/asynchooks/AsyncHooksScopeManager.test.ts index c29f6aa33f4..6e04d7f9850 100644 --- a/packages/opentelemetry-scope-async-hooks/test/asynchooks/AsyncHooksScopeManager.test.ts +++ b/packages/opentelemetry-scope-async-hooks/test/asynchooks/AsyncHooksScopeManager.test.ts @@ -63,6 +63,28 @@ describe('AsyncHooksScopeManager', () => { return done(); }); }); + + it('should rethrow errors', done => { + assert.throws(() => { + scopeManager.with(null, () => { + throw new Error('This should be rethrown'); + }); + }); + return done(); + }); + + it('should finally restore an old scope', done => { + const scope1 = 'scope1'; + const scope2 = 'scope2'; + scopeManager.with(scope1, () => { + assert.strictEqual(scopeManager.active(), 'scope1'); + scopeManager.with(scope2, () => { + assert.strictEqual(scopeManager.active(), 'scope2'); + }); + assert.strictEqual(scopeManager.active(), 'scope1'); + return done(); + }); + }); }); describe('.bind(function)', () => {