summaryrefslogtreecommitdiff
path: root/spec/frontend/helpers/jquery.js
blob: 4af5f904394ed18c8cf7ee4ffb05fb56f4058b2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import $ from 'jquery';

// Expose jQuery so specs using jQuery plugins can be imported nicely.
// Here is an issue to explore better alternatives:
// https://gitlab.com/gitlab-org/gitlab/issues/12448
global.$ = $;
global.jQuery = $;

// Fail tests for unmocked requests
$.ajax = () => {
  const err = new Error(
    'Unexpected unmocked jQuery.ajax() call! Make sure to mock jQuery.ajax() in tests.',
  );
  global.fail(err);
  throw err;
};

export default $;