From eb45cb8c99f4232da90c26b307eff35c926d1975 Mon Sep 17 00:00:00 2001 From: Martin Hanzel Date: Wed, 17 Jul 2019 17:47:39 +0000 Subject: Mockify jquery and axios packages Moved the block that fails tests on unmocked axios requests from test_setup to its own mock, and added a jQuery mock that fails tests if they use unmocked $.ajax(). --- spec/frontend/mocks/node/jquery.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 spec/frontend/mocks/node/jquery.js (limited to 'spec/frontend/mocks/node/jquery.js') diff --git a/spec/frontend/mocks/node/jquery.js b/spec/frontend/mocks/node/jquery.js new file mode 100644 index 00000000000..34a25772f67 --- /dev/null +++ b/spec/frontend/mocks/node/jquery.js @@ -0,0 +1,13 @@ +/* eslint-disable import/no-commonjs */ + +const $ = jest.requireActual('jquery'); + +// Fail tests for unmocked requests +$.ajax = () => { + throw new Error( + 'Unexpected unmocked jQuery.ajax() call! Make sure to mock jQuery.ajax() in tests.', + ); +}; + +// jquery is not an ES6 module +module.exports = $; -- cgit v1.2.1