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

document browser-only support #173

Closed maxbeatty closed 1 year ago

maxbeatty commented 1 year ago

Is your feature request related to a problem? Please describe. We use Karma in a browser to run our tests. The local server that is created uses Node.js dependencies that can't be provided ('http', 'net', 'path', etc.) so the tests fail to run. I thought I wanted a new feature of browser-only support that appears to already exist πŸŽ‰ https://github.com/zivl/sentry-testkit/blob/v5.0.5/src/browser.ts

Describe the solution you'd like Document this feature! (Sorry if I overlooked it πŸ™ˆ ). Our code ended up looking something like:

import sentryTestkit from 'sentry-testkit/dist/browser';

import { ErrorLogger } from './index';

const { sentryTransport, testkit } = sentryTestkit();

// abridged for clarity
const errorLogger = new ErrorLogger({
  transport: sentryTransport,
});

errorLogger.captureException(new Error('testing'));

testkit.reports()[0].error.message == 'testing'

Describe alternatives you've considered I considered writing my own stripped-down transport but thankfully won't have to πŸ˜…

Additional context Thanks for building this!

zivl commented 1 year ago

hey @maxbeatty! Actually you're right, it will be a good point for documentation and THIS IS the reason why we added sentry-testkit/dist/browser :) I'll try to add it soon, you're more than welcome to PR of-course

github-actions[bot] commented 1 year ago

Stale issue message