diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-25 12:08:48 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-25 12:08:48 +0000 |
commit | f7dae0cdcb70ecb71c1d65f099e9d96b27a4548c (patch) | |
tree | e53baffa847c4fd37c8e335e4d93d603c75f9f02 /doc/development | |
parent | b98fa9ef3d5bead417ae2f325cb64637883264e9 (diff) | |
download | gitlab-ce-f7dae0cdcb70ecb71c1d65f099e9d96b27a4548c.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'doc/development')
-rw-r--r-- | doc/development/event_tracking/frontend.md | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/doc/development/event_tracking/frontend.md b/doc/development/event_tracking/frontend.md index 4139bf2322d..42c82a745db 100644 --- a/doc/development/event_tracking/frontend.md +++ b/doc/development/event_tracking/frontend.md @@ -118,7 +118,31 @@ button.addEventListener('click', () => { ## Tests and test helpers -In Karma tests, you can use the following: +In Jest particularly in vue tests, you can use the following: + +```javascript +import { mockTracking } from 'helpers/tracking_helper'; + +describe('MyTracking', () => { + let spy; + + beforeEach(() => { + spy = mockTracking('_category_', wrapper.element, jest.spyOn); + }); + + it('tracks an event when clicked on feedback', () => { + wrapper.find('.discover-feedback-icon').trigger('click'); + + expect(spy).toHaveBeenCalledWith('_category_', 'click_button', { + label: 'security-discover-feedback-cta', + property: '0', + }); + }); +}); + +``` + +In obsolete Karma tests it's used as below: ```javascript import { mockTracking, triggerEvent } from 'spec/helpers/tracking_helper'; |