zivl / sentry-testkit

A Sentry plugin to allow Sentry report interception and further inspection of the data being sent
https://zivl.github.io/sentry-testkit/
MIT License
112 stars 26 forks source link

Using `scope.addEventProcessor` is...not working #24

Closed randallagordon closed 5 years ago

randallagordon commented 5 years ago

I'm still digging into it, but I've encountered an issue when using a scope and scope.addEventProcessor where neither captureEvent nor sendEvent seem to never get called. (We're using it to parse Koa requests via Sentry.Handlers.parseRequest in our implementation.)

If anyone happens to have an inkling of what might be going on, any insight would be greatly appreciated! I'll continue to try sorting it out, but in the mean time, as a starting point here's a test case that fails if it happens to be useful for anyone wandering into this as well. Simply removing the call to addEventProcessor allows it to pass:

  test('plays well with event processors', async function () {
    const err = new Error('sentry test kit is awesome!');
    Sentry.withScope(async scope => {
      scope.addEventProcessor(event => Sentry.Handlers.parseRequest(event, koaCtx.request));
      Sentry.captureException(err);
    });
    await waitForExpect(() => expect(testkit.reports()).toHaveLength(1));
    expect(testkit.reports()[0].exception).toMatchObject({
      values: [{ type: 'Error', value: 'sentry test kit is awesome!' }]
    });
  })
randallagordon commented 5 years ago

Scratch that—it works just fine...when there's a valid request object! Late Friday afternoon problems... 🙃