Commit f3c51e8f authored by Mark Florian's avatar Mark Florian Committed by Jose Ivan Vargas

Remove babel-plugin-rewire dependency

This is a follow-up to [removing most no-op default exports][1]. In that
MR, the "most" was due to the fact that a couple of files were still
participating in Karma tests.

Since it turns out that no Karma tests rely on `babel-plugin-rewire`,
that could be removed, allowing the final two instances of workarounds
for it to be removed as well.

Finally, the `spyOnDependency` helper was removed, since it's unused.

[1]: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/37213
parent 5a927024
......@@ -506,6 +506,3 @@ export const fetchVariableMetricLabelValues = ({ state, commit }, { defaultQuery
return Promise.all(optionsRequests);
};
// prevent babel-plugin-rewire from generating an invalid default during karma tests
export default () => {};
......@@ -170,6 +170,3 @@ export const getCustomVariablesParams = state =>
*/
export const fullDashboardPath = state =>
normalizeCustomDashboardPath(state.currentDashboard, state.customDashboardBasePath);
// prevent babel-plugin-rewire from generating an invalid default during karma tests
export default () => {};
......@@ -35,11 +35,6 @@ if (BABEL_ENV === 'coverage') {
]);
}
// add rewire support when running tests
if (BABEL_ENV === 'karma' || BABEL_ENV === 'coverage') {
plugins.push('babel-plugin-rewire');
}
// Jest is running in node environment, so we need additional plugins
const isJest = Boolean(process.env.JEST_WORKER_ID);
if (isJest) {
......
......@@ -92,11 +92,6 @@ const getDateFromMilestonesTooltip = ({
);
};
// This is for mocking methods from this
// file within tests using `spyOnDependency`
// which requires first param to always
// be default export of dependency as per
// https://gitlab.com/help/development/testing_guide/frontend_testing.md#stubbing-and-mocking
const epicUtils = {
gqClient,
triggerDocumentEvent,
......
/* eslint-disable
jasmine/no-global-setup, jasmine/no-unsafe-spy, no-underscore-dangle, no-console
jasmine/no-global-setup, no-underscore-dangle, no-console
*/
import $ from 'jquery';
......@@ -81,17 +81,6 @@ window.addEventListener('unhandledrejection', event => {
console.error(event.reason.stack || event.reason);
});
// Add global function to spy on a module's dependencies via rewire
window.spyOnDependency = (module, name) => {
const dependency = module.__GetDependency__(name);
const spy = jasmine.createSpy(name, dependency);
module.__Rewire__(name, spy);
return spy;
};
// Reset any rewired modules after each test (see babel-plugin-rewire)
afterEach(__rewire_reset_all__); // eslint-disable-line
// HACK: Chrome 59 disconnects if there are too many synchronous tests in a row
// because it appears to lock up the thread that communicates to Karma's socket
// This async beforeEach gets called on every spec and releases the JS thread long
......
......@@ -2156,11 +2156,6 @@ babel-plugin-lodash@^3.3.4:
lodash "^4.17.10"
require-package-name "^2.0.1"
babel-plugin-rewire@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/babel-plugin-rewire/-/babel-plugin-rewire-1.2.0.tgz#822562d72ed2c84e47c0f95ee232c920853e9d89"
integrity sha512-JBZxczHw3tScS+djy6JPLMjblchGhLI89ep15H3SyjujIzlxo5nr6Yjo7AXotdeVczeBmWs0tF8PgJWDdgzAkQ==
babel-preset-jest@^24.6.0:
version "24.6.0"
resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-24.6.0.tgz#66f06136eefce87797539c0d63f1769cc3915984"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment