summaryrefslogtreecommitdiff
path: root/spec/frontend/runner/sentry_utils_spec.js
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 09:55:51 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 09:55:51 +0000
commite8d2c2579383897a1dd7f9debd359abe8ae8373d (patch)
treec42be41678c2586d49a75cabce89322082698334 /spec/frontend/runner/sentry_utils_spec.js
parentfc845b37ec3a90aaa719975f607740c22ba6a113 (diff)
downloadgitlab-ce-8ed83bb76a87aac2ee8eb7e232a630a2b534ad93.tar.gz
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'spec/frontend/runner/sentry_utils_spec.js')
-rw-r--r--spec/frontend/runner/sentry_utils_spec.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/frontend/runner/sentry_utils_spec.js b/spec/frontend/runner/sentry_utils_spec.js
new file mode 100644
index 00000000000..b61eb63961e
--- /dev/null
+++ b/spec/frontend/runner/sentry_utils_spec.js
@@ -0,0 +1,39 @@
+import * as Sentry from '@sentry/browser';
+import { captureException } from '~/runner/sentry_utils';
+
+jest.mock('@sentry/browser');
+
+describe('~/runner/sentry_utils', () => {
+ let mockSetTag;
+
+ beforeEach(async () => {
+ mockSetTag = jest.fn();
+
+ Sentry.withScope.mockImplementation((fn) => {
+ const scope = { setTag: mockSetTag };
+ fn(scope);
+ });
+ });
+
+ describe('captureException', () => {
+ const mockError = new Error('Something went wrong!');
+
+ it('error is reported to sentry', () => {
+ captureException({ error: mockError });
+
+ expect(Sentry.withScope).toHaveBeenCalled();
+ expect(Sentry.captureException).toHaveBeenCalledWith(mockError);
+ });
+
+ it('error is reported to sentry with a component name', () => {
+ const mockComponentName = 'MyComponent';
+
+ captureException({ error: mockError, component: mockComponentName });
+
+ expect(Sentry.withScope).toHaveBeenCalled();
+ expect(Sentry.captureException).toHaveBeenCalledWith(mockError);
+
+ expect(mockSetTag).toHaveBeenCalledWith('vue_component', mockComponentName);
+ });
+ });
+});