Closed pptang closed 2 years ago
If Sentry.configureScope(...) is ever called and some scopes are being set (such as scope.setUser or scope.setTag, it cannot be reset, is it expected behaviour?
Sentry.configureScope(...)
scope.setUser
scope.setTag
describe('testkit.reset()', () => { it('does not reset Sentry scope', () => { Sentry.init({ dsn: 'https://dummy@sentry.io/000001', transport: sentryTransport, }); Sentry.configureScope(scope => { scope.setUser({ id: 'test-id' }); scope.setTag('tagName', 'test-tag'); }); Sentry.captureException(new Error('first exception')); expect(testkit.reports()).toHaveLength(1); expect(testkit.reports()[0].tags).toMatchObject({ tagName: 'test-tag' }); expect(testkit.reports()[0].user).toMatchObject({ id: 'test-id' }); testkit.reset(); expect(testkit.reports()).toHaveLength(0); Sentry.captureException(new Error('second exception')); // Expect to be empty, but it persists the previous scope values expect(testkit.reports()[0].tags).toBe({}); expect(testkit.reports()[0].user).toBe(undefined); }); });
hey @pptang , sorry for the delay. can you specify your sentry/sentry-testkit versions?
sentry
sentry-testkit
Stale issue message
Summary
If
Sentry.configureScope(...)
is ever called and some scopes are being set (such asscope.setUser
orscope.setTag
, it cannot be reset, is it expected behaviour?How to reproduce