routeError.spec.tsx 943 B

123456789101112131415161718192021222324252627282930313233343536
  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 {router} = initializeOrg({
  7. router: {
  8. routes: [
  9. {path: '/'},
  10. {path: '/:orgId/'},
  11. {name: 'this should be skipped'},
  12. {path: '/organizations/:orgId/'},
  13. {path: 'api-keys/', name: 'API Key'},
  14. ],
  15. },
  16. });
  17. it('captures errors with sentry', async function () {
  18. render(<RouteError error={new Error('Big Bad Error')} />, {
  19. router,
  20. });
  21. await waitFor(() =>
  22. expect(Sentry.captureException).toHaveBeenCalledWith(
  23. expect.objectContaining({
  24. message: 'Big Bad Error: /organizations/:orgId/api-keys/',
  25. })
  26. )
  27. );
  28. expect(Sentry.showReportDialog).toHaveBeenCalled();
  29. });
  30. });