routeError.spec.tsx 1008 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import * as Sentry from '@sentry/react';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  3. import {render, waitFor} from 'sentry-test/reactTestingLibrary';
  4. import RouteError from 'sentry/views/routeError';
  5. describe('RouteError', function () {
  6. const {routerContext} = initializeOrg({
  7. ...initializeOrg(),
  8. router: TestStubs.router({
  9. routes: [
  10. {path: '/'},
  11. {path: '/:orgId/'},
  12. {name: 'this should be skipped'},
  13. {path: '/organizations/:orgId/'},
  14. {path: 'api-keys/', name: 'API Key'},
  15. ],
  16. }),
  17. });
  18. it('captures errors with sentry', async function () {
  19. render(<RouteError error={new Error('Big Bad Error')} />, {
  20. context: routerContext,
  21. });
  22. await waitFor(() =>
  23. expect(Sentry.captureException).toHaveBeenCalledWith(
  24. expect.objectContaining({
  25. message: 'Big Bad Error: /organizations/:orgId/api-keys/',
  26. })
  27. )
  28. );
  29. expect(Sentry.showReportDialog).toHaveBeenCalled();
  30. });
  31. });