routeError.spec.jsx 956 B

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