From 30c7108955d86d9b860ef6e746ef1e707dbfe62f Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Sat, 6 Mar 2021 11:47:54 +0000 Subject: [PATCH] zjsunit: Remove rewiremock dependency. We now just use a module._load hook to inject stubs into our code. For conversion purposes I temporarily maintain the API of rewiremock, apart from the enable/disable pieces, but I will make a better wrapper in an upcoming commit. We can detect when rewiremock is called after zrequire now, and I fix all the violations in this commit, mostly by using override. We can also detect when a mock is needlessly created, and I fix all the violations in this commit. The one minor nuisance that this commit introduces is that you can only stub out modules in the Zulip source tree, which is now static/js. This should not really be a problem--there are usually better techniques to deal with third party depenencies. In the prior commit I show a typical workaround, which is to create a one-line wrapper in your test code. It's often the case that you can simply use override(), as well. In passing I kill off `reset_modules`, and I eliminated the second argument to zrequire, which dates back to pre-es6 days. --- frontend_tests/node_tests/activity.js | 13 +-- frontend_tests/node_tests/alert_words_ui.js | 6 +- frontend_tests/node_tests/billing.js | 8 +- frontend_tests/node_tests/billing_helpers.js | 8 +- frontend_tests/node_tests/bot_data.js | 7 +- frontend_tests/node_tests/buddy_data.js | 5 +- frontend_tests/node_tests/buddy_list.js | 6 +- frontend_tests/node_tests/channel.js | 6 +- frontend_tests/node_tests/compose.js | 36 ++++---- frontend_tests/node_tests/compose_actions.js | 7 +- frontend_tests/node_tests/compose_pm_pill.js | 12 +-- frontend_tests/node_tests/compose_state.js | 6 +- frontend_tests/node_tests/compose_video.js | 7 +- .../node_tests/composebox_typeahead.js | 13 +-- frontend_tests/node_tests/copy_and_paste.js | 6 +- frontend_tests/node_tests/dispatch.js | 11 +-- frontend_tests/node_tests/dispatch_subs.js | 15 ++-- frontend_tests/node_tests/drafts.js | 7 +- .../node_tests/dropdown_list_widget.js | 7 +- frontend_tests/node_tests/echo.js | 6 +- frontend_tests/node_tests/emoji.js | 4 +- frontend_tests/node_tests/emoji_picker.js | 4 +- frontend_tests/node_tests/fenced_code.js | 2 +- frontend_tests/node_tests/fetch_status.js | 7 +- frontend_tests/node_tests/filter.js | 9 +- frontend_tests/node_tests/hash_util.js | 9 +- frontend_tests/node_tests/hashchange.js | 7 +- frontend_tests/node_tests/hotkey.js | 17 ++-- frontend_tests/node_tests/input_pill.js | 7 +- frontend_tests/node_tests/lightbox.js | 11 +-- frontend_tests/node_tests/list_widget.js | 7 +- frontend_tests/node_tests/markdown.js | 10 +-- frontend_tests/node_tests/markdown_katex.js | 26 +++--- frontend_tests/node_tests/message_events.js | 6 +- frontend_tests/node_tests/message_fetch.js | 8 +- frontend_tests/node_tests/message_flags.js | 11 +-- frontend_tests/node_tests/message_list.js | 7 +- .../node_tests/message_list_data.js | 2 +- .../node_tests/message_list_view.js | 11 +-- frontend_tests/node_tests/message_store.js | 8 +- frontend_tests/node_tests/narrow.js | 12 +-- frontend_tests/node_tests/narrow_activate.js | 7 +- frontend_tests/node_tests/narrow_local.js | 10 +-- frontend_tests/node_tests/narrow_state.js | 2 +- frontend_tests/node_tests/narrow_unread.js | 9 +- frontend_tests/node_tests/password.js | 3 +- frontend_tests/node_tests/people.js | 6 +- frontend_tests/node_tests/people_errors.js | 6 +- frontend_tests/node_tests/pm_list.js | 7 +- frontend_tests/node_tests/popovers.js | 13 +-- frontend_tests/node_tests/presence.js | 6 +- frontend_tests/node_tests/reactions.js | 11 +-- frontend_tests/node_tests/recent_senders.js | 7 +- frontend_tests/node_tests/recent_topics.js | 7 +- .../node_tests/rendered_markdown.js | 7 +- frontend_tests/node_tests/scroll_util.js | 7 +- frontend_tests/node_tests/search.js | 9 +- frontend_tests/node_tests/search_legacy.js | 7 +- .../node_tests/search_suggestion.js | 9 +- .../node_tests/search_suggestion_legacy.js | 8 +- frontend_tests/node_tests/server_events.js | 33 ++++--- frontend_tests/node_tests/settings_bots.js | 12 +-- frontend_tests/node_tests/settings_emoji.js | 6 +- frontend_tests/node_tests/settings_muting.js | 6 +- frontend_tests/node_tests/settings_org.js | 8 +- .../node_tests/settings_profile_fields.js | 6 +- .../node_tests/settings_user_groups.js | 6 +- frontend_tests/node_tests/stream_edit.js | 7 +- frontend_tests/node_tests/stream_events.js | 9 +- frontend_tests/node_tests/stream_list.js | 20 ++--- frontend_tests/node_tests/stream_search.js | 7 +- .../node_tests/stream_topic_history.js | 7 +- frontend_tests/node_tests/submessage.js | 7 +- frontend_tests/node_tests/subs.js | 7 +- frontend_tests/node_tests/support.js | 2 +- frontend_tests/node_tests/top_left_corner.js | 23 ++--- frontend_tests/node_tests/topic_list_data.js | 7 +- frontend_tests/node_tests/transmit.js | 7 +- frontend_tests/node_tests/tutorial.js | 11 +-- frontend_tests/node_tests/typeahead.js | 2 +- frontend_tests/node_tests/typeahead_helper.js | 4 +- frontend_tests/node_tests/typing_status.js | 2 +- frontend_tests/node_tests/unread.js | 6 +- frontend_tests/node_tests/upgrade.js | 4 +- frontend_tests/node_tests/upload.js | 20 ++--- frontend_tests/node_tests/user_events.js | 7 +- frontend_tests/node_tests/user_status.js | 6 +- frontend_tests/node_tests/widgetize.js | 7 +- frontend_tests/zjsunit/index.js | 3 +- frontend_tests/zjsunit/namespace.js | 90 +++++++++++++++---- package.json | 1 - version.py | 2 +- yarn.lock | 78 +--------------- 93 files changed, 278 insertions(+), 663 deletions(-) diff --git a/frontend_tests/node_tests/activity.js b/frontend_tests/node_tests/activity.js index d0325f6168..c782fed7ea 100644 --- a/frontend_tests/node_tests/activity.js +++ b/frontend_tests/node_tests/activity.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -27,11 +25,6 @@ const _document = { const channel = {__esModule: true}; -const _ui = { - __esModule: true, - get_content_element: (element) => element, -}; - const _keydown_util = { __esModule: true, @@ -82,13 +75,10 @@ rewiremock("../../static/js/popovers").with(_popovers); rewiremock("../../static/js/resize").with(_resize); rewiremock("../../static/js/scroll_util").with(_scroll_util); rewiremock("../../static/js/stream_popover").with(_stream_popover); -rewiremock("../../static/js/ui").with(_ui); rewiremock("../../static/js/server_events").with({ check_for_unsuspend() {}, }); -rewiremock.enable(); - const huddle_data = zrequire("huddle_data"); const compose_fade = zrequire("compose_fade"); const narrow = zrequire("narrow"); @@ -760,4 +750,3 @@ test_ui("test_send_or_receive_no_presence_for_web_public_visitor", () => { page_params.is_web_public_visitor = true; activity.send_presence_to_server(); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/alert_words_ui.js b/frontend_tests/node_tests/alert_words_ui.js index fdc5d5cf05..32571aa6fa 100644 --- a/frontend_tests/node_tests/alert_words_ui.js +++ b/frontend_tests/node_tests/alert_words_ui.js @@ -2,17 +2,14 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - const {stub_templates} = require("../zjsunit/handlebars"); -const {zrequire} = require("../zjsunit/namespace"); +const {rewiremock, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); const channel = {__esModule: true}; rewiremock("../../static/js/channel").with(channel); -rewiremock.enable(); const alert_words = zrequire("alert_words"); const alert_words_ui = zrequire("alert_words_ui"); @@ -197,4 +194,3 @@ run_test("close_status_message", (override) => { close(event); assert(!alert.visible()); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/billing.js b/frontend_tests/node_tests/billing.js index 31a9236eaf..95de9d1d7a 100644 --- a/frontend_tests/node_tests/billing.js +++ b/frontend_tests/node_tests/billing.js @@ -4,9 +4,8 @@ const {strict: assert} = require("assert"); const fs = require("fs"); const {JSDOM} = require("jsdom"); -const rewiremock = require("rewiremock/node"); -const {set_global, with_field, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, with_field, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -23,8 +22,6 @@ const StripeCheckout = set_global("StripeCheckout", { configure: () => {}, }); -rewiremock.enable(); - run_test("initialize", (override) => { let token_func; @@ -72,7 +69,7 @@ run_test("initialize", (override) => { $("#payment-method").data = (key) => document.querySelector("#payment-method").getAttribute("data-" + key); - zrequire("billing", "js/billing/billing"); + zrequire("billing/billing"); assert(set_tab_called); assert(stripe_checkout_configure_called); @@ -112,4 +109,3 @@ run_test("billing_template", () => { assert(document.querySelector("input[name=csrfmiddlewaretoken]")); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/billing_helpers.js b/frontend_tests/node_tests/billing_helpers.js index d7798d0d7a..6a85167817 100644 --- a/frontend_tests/node_tests/billing_helpers.js +++ b/frontend_tests/node_tests/billing_helpers.js @@ -5,9 +5,8 @@ const fs = require("fs"); const jQueryFactory = require("jquery"); const {JSDOM} = require("jsdom"); -const rewiremock = require("rewiremock/node"); -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -28,9 +27,7 @@ set_global("location", { hash: "#billing", }); -rewiremock.enable(); - -const helpers = zrequire("helpers", "js/billing/helpers"); +const helpers = zrequire("billing/helpers"); run_test("create_ajax_request", (override) => { const form_loading_indicator = "#autopay_loading_indicator"; @@ -290,4 +287,3 @@ run_test("set_tab", () => { assert.equal(state.show_tab_payment_method, 1); assert.equal(state.scrollTop, 2); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/bot_data.js b/frontend_tests/node_tests/bot_data.js index 3aad29f122..b493c8518c 100644 --- a/frontend_tests/node_tests/bot_data.js +++ b/frontend_tests/node_tests/bot_data.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {zrequire} = require("../zjsunit/namespace"); +const {rewiremock, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const _settings_bots = { @@ -14,8 +12,6 @@ const _settings_bots = { rewiremock("../../static/js/settings_bots").with(_settings_bots); -rewiremock.enable(); - const bot_data = zrequire("bot_data"); const people = zrequire("people"); @@ -176,4 +172,3 @@ run_test("test_basics", () => { assert.equal(bots[1].email, "bot2@zulip.com"); })(); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/buddy_data.js b/frontend_tests/node_tests/buddy_data.js index 87d12f9900..5cb2158bdb 100644 --- a/frontend_tests/node_tests/buddy_data.js +++ b/frontend_tests/node_tests/buddy_data.js @@ -3,9 +3,8 @@ const {strict: assert} = require("assert"); const _ = require("lodash"); -const rewiremock = require("rewiremock/node"); -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const page_params = set_global("page_params", {}); @@ -13,7 +12,6 @@ const page_params = set_global("page_params", {}); const timerender = {__esModule: true}; rewiremock("../../static/js/timerender").with(timerender); -rewiremock.enable(); const people = zrequire("people"); const presence = zrequire("presence"); @@ -355,4 +353,3 @@ run_test("error handling", (override) => { blueslip.expect("warn", "Got user_id in presence but not people: 42"); buddy_data.get_filtered_and_sorted_user_ids(); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/buddy_list.js b/frontend_tests/node_tests/buddy_list.js index d21b879e4c..5e696ca605 100644 --- a/frontend_tests/node_tests/buddy_list.js +++ b/frontend_tests/node_tests/buddy_list.js @@ -3,9 +3,8 @@ const {strict: assert} = require("assert"); const _ = require("lodash"); -const rewiremock = require("rewiremock/node"); -const {zrequire} = require("../zjsunit/namespace"); +const {rewiremock, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -17,8 +16,6 @@ rewiremock("../../static/js/message_viewport").with({ height: () => 550, }); -rewiremock.enable(); - const people = zrequire("people"); const {buddy_list} = zrequire("buddy_list"); @@ -226,4 +223,3 @@ run_test("scrolling", (override) => { assert(tried_to_fill); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/channel.js b/frontend_tests/node_tests/channel.js index 0131d6999a..ef134d7e62 100644 --- a/frontend_tests/node_tests/channel.js +++ b/frontend_tests/node_tests/channel.js @@ -3,9 +3,8 @@ const {strict: assert} = require("assert"); const _ = require("lodash"); -const rewiremock = require("rewiremock/node"); -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const reload = {__esModule: true}; @@ -17,8 +16,6 @@ set_global("setTimeout", (f, delay) => { f(); }); -rewiremock.enable(); - const channel = zrequire("channel"); const default_stub_xhr = "default-stub-xhr"; @@ -315,4 +312,3 @@ run_test("xhr_error_message", () => { msg = "some message"; assert.equal(channel.xhr_error_message(msg, xhr), "some message: file not found"); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/compose.js b/frontend_tests/node_tests/compose.js index b11b361c1c..b031b9ce88 100644 --- a/frontend_tests/node_tests/compose.js +++ b/frontend_tests/node_tests/compose.js @@ -4,10 +4,9 @@ const {strict: assert} = require("assert"); const {JSDOM} = require("jsdom"); const MockDate = require("mockdate"); -const rewiremock = require("rewiremock/node"); const {stub_templates} = require("../zjsunit/handlebars"); -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -27,6 +26,8 @@ rewiremock("../../static/js/compose_actions").with({ }, }); +const server_events = rewiremock("../../static/js/server_events").with({__esModule: true}); + const _navigator = { platform: "", }; @@ -97,8 +98,7 @@ document.location.host = "foo.com"; const fake_now = 555; MockDate.set(new Date(fake_now * 1000)); -rewiremock.enable(); - +const compose_fade = zrequire("compose_fade"); const peer_data = zrequire("peer_data"); const util = zrequire("util"); const rtl = zrequire("rtl"); @@ -716,7 +716,7 @@ test_ui("send_message_success", () => { assert(reify_message_id_checked); }); -test_ui("send_message", () => { +test_ui("send_message", (override) => { // This is the common setup stuff for all of the four tests. let stub_state; function initialize_state_stub_dict() { @@ -730,10 +730,9 @@ test_ui("send_message", () => { set_global("setTimeout", (func) => { func(); }); - rewiremock("../../static/js/server_events").with({ - assert_get_events_running() { - stub_state.get_events_running_called += 1; - }, + + override(server_events, "assert_get_events_running", () => { + stub_state.get_events_running_called += 1; }); // Tests start here. @@ -1105,7 +1104,7 @@ test_ui("initialize", (override) => { })(); }); -test_ui("update_fade", () => { +test_ui("update_fade", (override) => { const selector = "#stream_message_recipient_stream,#stream_message_recipient_topic,#private_message_recipient"; const keyup_handler_func = $(selector).get_on_handler("keyup"); @@ -1113,14 +1112,13 @@ test_ui("update_fade", () => { let set_focused_recipient_checked = false; let update_all_called = false; - rewiremock("../../static/js/compose_fade").with({ - set_focused_recipient(msg_type) { - assert.equal(msg_type, "private"); - set_focused_recipient_checked = true; - }, - update_all() { - update_all_called = true; - }, + override(compose_fade, "set_focused_recipient", (msg_type) => { + assert.equal(msg_type, "private"); + set_focused_recipient_checked = true; + }); + + override(compose_fade, "update_all", () => { + update_all_called = true; }); compose_state.set_message_type(false); @@ -1729,5 +1727,3 @@ test_ui("narrow_button_titles", () => { }); MockDate.reset(); - -rewiremock.disable(); diff --git a/frontend_tests/node_tests/compose_actions.js b/frontend_tests/node_tests/compose_actions.js index c10754a86f..1e38da092e 100644 --- a/frontend_tests/node_tests/compose_actions.js +++ b/frontend_tests/node_tests/compose_actions.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -69,8 +67,6 @@ const channel = {__esModule: true}; rewiremock("../../static/js/channel").with(channel); -rewiremock.enable(); - const people = zrequire("people"); const compose_ui = zrequire("compose_ui"); const compose = zrequire("compose"); @@ -502,4 +498,3 @@ run_test("on_narrow", (override) => { }); assert(cancel_called); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/compose_pm_pill.js b/frontend_tests/node_tests/compose_pm_pill.js index 0852c0f5dc..574b370a4a 100644 --- a/frontend_tests/node_tests/compose_pm_pill.js +++ b/frontend_tests/node_tests/compose_pm_pill.js @@ -2,21 +2,16 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {zrequire} = require("../zjsunit/namespace"); +const {rewiremock, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); -rewiremock.enable(); +const compose_actions = {__esModule: true}; +rewiremock("../../static/js/compose_actions").with(compose_actions); const people = zrequire("people"); - const compose_pm_pill = zrequire("compose_pm_pill"); const input_pill = zrequire("input_pill"); -const compose_actions = {__esModule: true}; - -rewiremock("../../static/js/compose_actions").with(compose_actions); let pills = { pill: {}, @@ -199,4 +194,3 @@ run_test("has_unconverted_data", () => { // we have some unconverted data. assert.equal(compose_pm_pill.has_unconverted_data(), true); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/compose_state.js b/frontend_tests/node_tests/compose_state.js index 1635eb8423..1b06aa6923 100644 --- a/frontend_tests/node_tests/compose_state.js +++ b/frontend_tests/node_tests/compose_state.js @@ -2,12 +2,9 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {zrequire} = require("../zjsunit/namespace"); +const {rewiremock, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); -rewiremock.enable(); const compose_pm_pill = {__esModule: true}; rewiremock("../../static/js/compose_pm_pill").with(compose_pm_pill); @@ -25,4 +22,3 @@ run_test("private_message_recipient", (override) => { compose_state.private_message_recipient("fred@fred.org"); assert.equal(compose_state.private_message_recipient(), "fred@fred.org"); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/compose_video.js b/frontend_tests/node_tests/compose_video.js index 04f93127bf..09bc669986 100644 --- a/frontend_tests/node_tests/compose_video.js +++ b/frontend_tests/node_tests/compose_video.js @@ -2,16 +2,12 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); const events = require("./lib/events"); -rewiremock.enable(); - const resize = { __esModule: true, watch_manual_resize() {}, @@ -253,4 +249,3 @@ run_test("test_video_chat_button_toggle enabled", (override) => { compose.initialize(); assert.equal($("#below-compose-content .video_link").visible(), true); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/composebox_typeahead.js b/frontend_tests/node_tests/composebox_typeahead.js index 592c42c577..960bbcf9d3 100644 --- a/frontend_tests/node_tests/composebox_typeahead.js +++ b/frontend_tests/node_tests/composebox_typeahead.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -45,10 +43,8 @@ set_global("setTimeout", (f, time) => { }); set_global("document", "document-stub"); -rewiremock.enable(); - -const emoji = zrequire("emoji", "shared/js/emoji"); -const typeahead = zrequire("typeahead", "shared/js/typeahead"); +const emoji = zrequire("../shared/js/emoji"); +const typeahead = zrequire("../shared/js/typeahead"); const compose_state = zrequire("compose_state"); zrequire("user_status"); zrequire("presence"); @@ -63,7 +59,7 @@ const user_pill = zrequire("user_pill"); const compose_pm_pill = zrequire("compose_pm_pill"); const composebox_typeahead = zrequire("composebox_typeahead"); const settings_config = zrequire("settings_config"); -const pygments_data = zrequire("pygments_data", "generated/pygments_data.json"); +const pygments_data = zrequire("../generated/pygments_data.json"); // To be eliminated in next commit: stream_data.__Rewire__("update_calculated_fields", () => {}); @@ -1567,4 +1563,3 @@ run_test("message people", () => { // harry is excluded since it has been deactivated. assert.deepEqual(results, [hamletcharacters, hal]); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/copy_and_paste.js b/frontend_tests/node_tests/copy_and_paste.js index f8ab47325b..c8645d760a 100644 --- a/frontend_tests/node_tests/copy_and_paste.js +++ b/frontend_tests/node_tests/copy_and_paste.js @@ -4,9 +4,8 @@ const {strict: assert} = require("assert"); const jquery = require("jquery"); const {JSDOM} = require("jsdom"); -const rewiremock = require("rewiremock/node"); -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); set_global("page_params", { @@ -23,8 +22,6 @@ const $ = set_global("$", jquery(window)); set_global("DOMParser", DOMParser); set_global("document", document); -rewiremock.enable(); - const copy_and_paste = zrequire("copy_and_paste"); // Super stripped down version of the code in the drag-mock library @@ -116,4 +113,3 @@ run_test("paste_handler", () => { copy_and_paste.paste_handler(event); assert(!insert_syntax_and_focus_called); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/dispatch.js b/frontend_tests/node_tests/dispatch.js index 06c628c25b..5a556fa061 100644 --- a/frontend_tests/node_tests/dispatch.js +++ b/frontend_tests/node_tests/dispatch.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {make_stub} = require("../zjsunit/stub"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -112,8 +110,6 @@ const page_params = set_global("page_params", { realm_description: "already set description", }); -rewiremock.enable(); - // For data-oriented modules, just use them, don't stub them. const alert_words = zrequire("alert_words"); const stream_topic_history = zrequire("stream_topic_history"); @@ -123,7 +119,7 @@ const people = zrequire("people"); const starred_messages = zrequire("starred_messages"); const user_status = zrequire("user_status"); -const emoji = zrequire("emoji", "shared/js/emoji"); +const emoji = zrequire("../shared/js/emoji"); const server_events_dispatch = zrequire("server_events_dispatch"); @@ -137,7 +133,7 @@ people.add_active_user(test_user); message_store.add_message_metadata(test_message); const realm_emoji = {}; -const emoji_codes = zrequire("emoji_codes", "generated/emoji/emoji_codes.json"); +const emoji_codes = zrequire("../generated/emoji/emoji_codes.json"); emoji.initialize({realm_emoji, emoji_codes}); @@ -893,4 +889,3 @@ run_test("realm_export", (override) => { const args = stub.get_args("exports"); assert.equal(args.exports, event.exports); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/dispatch_subs.js b/frontend_tests/node_tests/dispatch_subs.js index b803072884..88fdb472f9 100644 --- a/frontend_tests/node_tests/dispatch_subs.js +++ b/frontend_tests/node_tests/dispatch_subs.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {make_stub} = require("../zjsunit/stub"); const {run_test} = require("../zjsunit/test"); @@ -21,12 +19,6 @@ const subs = {__esModule: true}; rewiremock("../../static/js/subs").with(subs); -rewiremock.enable(); - -const peer_data = zrequire("peer_data"); -const people = zrequire("people"); -const stream_data = zrequire("stream_data"); - set_global("current_msg_list", {}); const narrow_state = {__esModule: true}; rewiremock("../../static/js/narrow_state").with(narrow_state); @@ -41,6 +33,10 @@ const stream_list = {__esModule: true}; rewiremock("../../static/js/stream_list").with(stream_list); +const peer_data = zrequire("peer_data"); +const people = zrequire("people"); +const stream_data = zrequire("stream_data"); + const server_events_dispatch = zrequire("server_events_dispatch"); const noop = () => {}; @@ -280,4 +276,3 @@ test("stream delete (special streams)", (override) => { assert.equal(page_params.realm_notifications_stream_id, -1); assert.equal(page_params.realm_signup_notifications_stream_id, -1); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/drafts.js b/frontend_tests/node_tests/drafts.js index 86a3be13b5..f670828ba6 100644 --- a/frontend_tests/node_tests/drafts.js +++ b/frontend_tests/node_tests/drafts.js @@ -2,10 +2,8 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - const {stub_templates} = require("../zjsunit/handlebars"); -const {set_global, zrequire, with_overrides} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire, with_overrides} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -40,8 +38,6 @@ set_global("page_params", { twenty_four_hour_time: false, }); -rewiremock.enable(); - const {localstorage} = zrequire("localstorage"); const drafts = zrequire("drafts"); const timerender = zrequire("timerender"); @@ -304,4 +300,3 @@ run_test("format_drafts", (override) => { drafts.launch(); timerender.__Rewire__("render_now", stub_render_now); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/dropdown_list_widget.js b/frontend_tests/node_tests/dropdown_list_widget.js index 22a0bd6f74..fa96e54fe8 100644 --- a/frontend_tests/node_tests/dropdown_list_widget.js +++ b/frontend_tests/node_tests/dropdown_list_widget.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {zrequire} = require("../zjsunit/namespace"); +const {rewiremock, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -15,8 +13,6 @@ const _ListWidget = { }; rewiremock("../../static/js/list_widget").with(_ListWidget); -rewiremock.enable(); - const {DropdownListWidget: dropdown_list_widget} = zrequire("dropdown_list_widget"); const setup_zjquery_data = (name) => { @@ -79,4 +75,3 @@ run_test("no_default_value", () => { const widget = dropdown_list_widget(opts); assert.equal(widget.value(), "null-value"); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/echo.js b/frontend_tests/node_tests/echo.js index 3d4974833d..abeb27920b 100644 --- a/frontend_tests/node_tests/echo.js +++ b/frontend_tests/node_tests/echo.js @@ -3,9 +3,8 @@ const {strict: assert} = require("assert"); const MockDate = require("mockdate"); -const rewiremock = require("rewiremock/node"); -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const local_message = {__esModule: true}; @@ -47,8 +46,6 @@ rewiremock("../../static/js/message_list").with({}); set_global("current_msg_list", ""); -rewiremock.enable(); - const echo = zrequire("echo"); const people = zrequire("people"); @@ -264,4 +261,3 @@ run_test("insert_local_message PM", (override) => { }); MockDate.reset(); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/emoji.js b/frontend_tests/node_tests/emoji.js index 5a6a86364c..446cf06c05 100644 --- a/frontend_tests/node_tests/emoji.js +++ b/frontend_tests/node_tests/emoji.js @@ -5,11 +5,11 @@ const {strict: assert} = require("assert"); const {zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); -const emoji_codes = zrequire("emoji_codes", "generated/emoji/emoji_codes.json"); +const emoji_codes = zrequire("../generated/emoji/emoji_codes.json"); const events = require("./lib/events"); -const emoji = zrequire("emoji", "shared/js/emoji"); +const emoji = zrequire("../shared/js/emoji"); const realm_emoji = events.test_realm_emojis; diff --git a/frontend_tests/node_tests/emoji_picker.js b/frontend_tests/node_tests/emoji_picker.js index cf9198ef19..517f072dc8 100644 --- a/frontend_tests/node_tests/emoji_picker.js +++ b/frontend_tests/node_tests/emoji_picker.js @@ -7,10 +7,10 @@ const _ = require("lodash"); const {zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); -const emoji = zrequire("emoji", "shared/js/emoji"); +const emoji = zrequire("../shared/js/emoji"); const emoji_picker = zrequire("emoji_picker"); -const emoji_codes = zrequire("emoji_codes", "generated/emoji/emoji_codes.json"); +const emoji_codes = zrequire("../generated/emoji/emoji_codes.json"); run_test("initialize", () => { emoji.initialize({ diff --git a/frontend_tests/node_tests/fenced_code.js b/frontend_tests/node_tests/fenced_code.js index 25634765ff..132f2c806a 100644 --- a/frontend_tests/node_tests/fenced_code.js +++ b/frontend_tests/node_tests/fenced_code.js @@ -5,7 +5,7 @@ const {strict: assert} = require("assert"); const {zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); -const fenced_code = zrequire("fenced_code", "shared/js/fenced_code"); +const fenced_code = zrequire("../shared/js/fenced_code"); run_test("get_unused_fence", () => { assert.equal(fenced_code.get_unused_fence("```js\nsomething\n```"), "`".repeat(4)); diff --git a/frontend_tests/node_tests/fetch_status.js b/frontend_tests/node_tests/fetch_status.js index 4384809ee6..ac987beb37 100644 --- a/frontend_tests/node_tests/fetch_status.js +++ b/frontend_tests/node_tests/fetch_status.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {zrequire} = require("../zjsunit/namespace"); +const {rewiremock, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); rewiremock("../../static/js/message_scroll").with({ @@ -14,8 +12,6 @@ rewiremock("../../static/js/message_scroll").with({ show_loading_newer: () => {}, }); -rewiremock.enable(); - const {FetchStatus} = zrequire("fetch_status"); let fetch_status = new FetchStatus(); @@ -180,4 +176,3 @@ run_test("basics", () => { can_load_older(); blocked_newer(); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/filter.js b/frontend_tests/node_tests/filter.js index 2a84a1634b..3d90f34bab 100644 --- a/frontend_tests/node_tests/filter.js +++ b/frontend_tests/node_tests/filter.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -12,11 +10,9 @@ const message_store = {__esModule: true}; rewiremock("../../static/js/message_store").with(message_store); const page_params = set_global("page_params", {}); -rewiremock.enable(); - const stream_data = zrequire("stream_data"); const people = zrequire("people"); -const {Filter} = zrequire("Filter", "js/filter"); +const {Filter} = zrequire("../js/filter"); const me = { email: "me@example.com", @@ -1556,4 +1552,3 @@ run_test("error_cases", () => { const predicate = get_predicate([["pm-with", "Joe@example.com"]]); assert(!predicate({type: "private"})); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/hash_util.js b/frontend_tests/node_tests/hash_util.js index 957b07a66e..de4479d33a 100644 --- a/frontend_tests/node_tests/hash_util.js +++ b/frontend_tests/node_tests/hash_util.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const ui_report = { @@ -22,12 +20,10 @@ set_global("location", { pathname: "/", }); -rewiremock.enable(); - const hash_util = zrequire("hash_util"); const stream_data = zrequire("stream_data"); const people = zrequire("people"); -const {Filter} = zrequire("Filter", "js/filter"); +const {Filter} = zrequire("../js/filter"); const narrow_state = zrequire("narrow_state"); const hamlet = { @@ -179,4 +175,3 @@ run_test("test_search_public_streams_notice_url", () => { "#narrow/streams/public/sender/15-hamlet", ); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/hashchange.js b/frontend_tests/node_tests/hashchange.js index efc9061958..27fc5a0798 100644 --- a/frontend_tests/node_tests/hashchange.js +++ b/frontend_tests/node_tests/hashchange.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -46,8 +44,6 @@ rewiremock("../../static/js/top_left_corner").with({ handle_narrow_deactivated: () => {}, }); -rewiremock.enable(); - const people = zrequire("people"); const hash_util = zrequire("hash_util"); const hashchange = zrequire("hashchange"); @@ -317,4 +313,3 @@ run_test("save_narrow", () => { helper.assert_events([[message_viewport, "stop_auto_scrolling"]]); assert.equal(url_pushed, "http://example.com/#narrow/is/starred"); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/hotkey.js b/frontend_tests/node_tests/hotkey.js index 38b5ea8c3a..ff29f39565 100644 --- a/frontend_tests/node_tests/hotkey.js +++ b/frontend_tests/node_tests/hotkey.js @@ -2,9 +2,13 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, with_field, with_overrides, zrequire} = require("../zjsunit/namespace"); +const { + rewiremock, + set_global, + with_field, + with_overrides, + zrequire, +} = require("../zjsunit/namespace"); const {make_stub} = require("../zjsunit/stub"); const {run_test} = require("../zjsunit/test"); @@ -130,10 +134,8 @@ rewiremock("../../static/js/recent_topics").with({ is_visible: () => false, }); -rewiremock.enable(); - -const emoji_codes = zrequire("emoji_codes", "generated/emoji/emoji_codes.json"); -const emoji = zrequire("emoji", "shared/js/emoji"); +const emoji_codes = zrequire("../generated/emoji/emoji_codes.json"); +const emoji = zrequire("../shared/js/emoji"); const activity = zrequire("activity"); const hotkey = zrequire("hotkey"); @@ -522,4 +524,3 @@ run_test("motion_keys", () => { overlays.is_active = () => false; overlays.drafts_open = () => false; }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/input_pill.js b/frontend_tests/node_tests/input_pill.js index cfeaf74d26..e162345706 100644 --- a/frontend_tests/node_tests/input_pill.js +++ b/frontend_tests/node_tests/input_pill.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -21,8 +19,6 @@ set_global("getSelection", () => ({ anchorOffset: 0, })); -rewiremock.enable(); - zrequire("templates"); const input_pill = zrequire("input_pill"); @@ -604,4 +600,3 @@ run_test("appendValue/clear", () => { assert.deepEqual(removed_colors, ["blue", "yellow", "red"]); assert.equal(pill_input[0].textContent, ""); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/lightbox.js b/frontend_tests/node_tests/lightbox.js index b388b4a6a5..f35364bd30 100644 --- a/frontend_tests/node_tests/lightbox.js +++ b/frontend_tests/node_tests/lightbox.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -18,13 +16,11 @@ rewiremock("../../static/js/popovers").with({ hide_all: () => {}, }); -rewiremock.enable(); +const message_store = {__esModule: true}; +rewiremock("../../static/js/message_store").with(message_store); const rows = zrequire("rows"); const lightbox = zrequire("lightbox"); -const message_store = {__esModule: true}; - -rewiremock("../../static/js/message_store").with(message_store); rows.__Rewire__("is_draft_row", () => false); @@ -90,4 +86,3 @@ run_test("youtube", (override) => { lightbox.open(img); assert.equal($(".image-actions .open").attr("href"), href); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/list_widget.js b/frontend_tests/node_tests/list_widget.js index 355c413cb9..688c7a0522 100644 --- a/frontend_tests/node_tests/list_widget.js +++ b/frontend_tests/node_tests/list_widget.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); // We need these stubs to get by instanceof checks. @@ -36,8 +34,6 @@ set_global("$", (arg) => { }; }); -rewiremock.enable(); - const ListWidget = zrequire("list_widget"); // We build objects here that simulate jQuery containers. @@ -780,4 +776,3 @@ run_test("render item", () => { widget_3.render_item(item); blueslip.reset(); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/markdown.js b/frontend_tests/node_tests/markdown.js index ab31be1af8..1b2face147 100644 --- a/frontend_tests/node_tests/markdown.js +++ b/frontend_tests/node_tests/markdown.js @@ -32,12 +32,12 @@ set_global("Image", Image); const doc = ""; set_global("document", doc); -const emoji = zrequire("emoji", "shared/js/emoji"); -const emoji_codes = zrequire("emoji_codes", "generated/emoji/emoji_codes.json"); -const pygments_data = zrequire("pygments_data", "generated/pygments_data.json"); -const fenced_code = zrequire("fenced_code", "shared/js/fenced_code"); +const emoji = zrequire("../shared/js/emoji"); +const emoji_codes = zrequire("../generated/emoji/emoji_codes.json"); +const pygments_data = zrequire("../generated/pygments_data.json"); +const fenced_code = zrequire("../shared/js/fenced_code"); const markdown_config = zrequire("markdown_config"); -const marked = zrequire("marked", "third/marked/lib/marked"); +const marked = zrequire("../third/marked/lib/marked"); const markdown = zrequire("markdown"); const people = zrequire("people"); const stream_data = zrequire("stream_data"); diff --git a/frontend_tests/node_tests/markdown_katex.js b/frontend_tests/node_tests/markdown_katex.js index c1c253567d..cdde8fb44f 100644 --- a/frontend_tests/node_tests/markdown_katex.js +++ b/frontend_tests/node_tests/markdown_katex.js @@ -7,19 +7,10 @@ There may be a better way. */ -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {set_global, with_field, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); set_global("page_params", {}); -rewiremock("katex").with({ - renderToString: () => { - throw new Error("some-exception"); - }, -}); - -rewiremock.enable(); const markdown_config = zrequire("markdown_config"); @@ -30,7 +21,16 @@ markdown.initialize([], markdown_config.get_helpers()); run_test("katex_throws_unexpected_exceptions", () => { blueslip.expect("error", "Error: some-exception"); const message = {raw_content: "$$a$$"}; - markdown.apply_markdown(message); + with_field( + markdown, + "katex", + { + renderToString: () => { + throw new Error("some-exception"); + }, + }, + () => { + markdown.apply_markdown(message); + }, + ); }); - -rewiremock.disable(); diff --git a/frontend_tests/node_tests/message_events.js b/frontend_tests/node_tests/message_events.js index 97e192278e..b0753cd4b1 100644 --- a/frontend_tests/node_tests/message_events.js +++ b/frontend_tests/node_tests/message_events.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const condense = {__esModule: true}; @@ -24,7 +22,6 @@ rewiremock("../../static/js/stream_list").with(stream_list); const unread_ui = {__esModule: true}; rewiremock("../../static/js/unread_ui").with(unread_ui); -rewiremock.enable(); const message_events = zrequire("message_events"); const message_store = zrequire("message_store"); @@ -160,4 +157,3 @@ run_test("update_messages", () => { }, ]); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/message_fetch.js b/frontend_tests/node_tests/message_fetch.js index 72800c2ee3..857010b600 100644 --- a/frontend_tests/node_tests/message_fetch.js +++ b/frontend_tests/node_tests/message_fetch.js @@ -3,9 +3,8 @@ const {strict: assert} = require("assert"); const _ = require("lodash"); -const rewiremock = require("rewiremock/node"); -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -54,10 +53,8 @@ const stream_list = { rewiremock("../../static/js/stream_list").with(stream_list); -rewiremock.enable(); - const message_fetch = zrequire("message_fetch"); -const {Filter} = zrequire("Filter", "js/filter"); +const {Filter} = zrequire("../js/filter"); const message_list = zrequire("message_list"); const people = zrequire("people"); @@ -482,4 +479,3 @@ run_test("loading_newer", () => { assert.equal(msg_list.data.fetch_status.can_load_newer_messages(), false); })(); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/message_flags.js b/frontend_tests/node_tests/message_flags.js index 5465e9f75e..12a8cd27e5 100644 --- a/frontend_tests/node_tests/message_flags.js +++ b/frontend_tests/node_tests/message_flags.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); rewiremock("../../static/js/starred_messages").with({ @@ -12,16 +10,14 @@ rewiremock("../../static/js/starred_messages").with({ remove: () => {}, }); -rewiremock.enable(); - -const message_flags = zrequire("message_flags"); - const ui = {__esModule: true}; rewiremock("../../static/js/ui").with(ui); const channel = {__esModule: true}; rewiremock("../../static/js/channel").with(channel); +const message_flags = zrequire("message_flags"); + run_test("starred", () => { const message = { id: 50, @@ -171,4 +167,3 @@ run_test("read", () => { success: channel_post_opts.success, }); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/message_list.js b/frontend_tests/node_tests/message_list.js index de6bba7b6e..81ce19fff0 100644 --- a/frontend_tests/node_tests/message_list.js +++ b/frontend_tests/node_tests/message_list.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {make_stub} = require("../zjsunit/stub"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -31,8 +29,6 @@ rewiremock("../../static/js/narrow_state").with(narrow_state); const stream_data = {__esModule: true}; rewiremock("../../static/js/stream_data").with(stream_data); -rewiremock.enable(); - const muting = zrequire("muting"); const {MessageList} = zrequire("message_list"); @@ -444,4 +440,3 @@ run_test("add_remove_rerender", () => { assert.equal(list.num_items(), 0); } }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/message_list_data.js b/frontend_tests/node_tests/message_list_data.js index 9ec38b180f..8a7dd8a394 100644 --- a/frontend_tests/node_tests/message_list_data.js +++ b/frontend_tests/node_tests/message_list_data.js @@ -13,7 +13,7 @@ set_global("setTimeout", (f, delay) => { }); const muting = zrequire("muting"); -const {MessageListData} = zrequire("MessageListData", "js/message_list_data"); +const {MessageListData} = zrequire("../js/message_list_data"); function make_msg(msg_id) { return { diff --git a/frontend_tests/node_tests/message_list_view.js b/frontend_tests/node_tests/message_list_view.js index d9e7664400..45d55793f0 100644 --- a/frontend_tests/node_tests/message_list_view.js +++ b/frontend_tests/node_tests/message_list_view.js @@ -3,9 +3,8 @@ const {strict: assert} = require("assert"); const _ = require("lodash"); -const rewiremock = require("rewiremock/node"); -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); set_global("document", "document-stub"); @@ -16,7 +15,6 @@ const page_params = set_global("page_params", { twenty_four_hour_time: false, }); set_global("home_msg_list", "stub"); -rewiremock("../../static/js/unread").with({message_unread() {}}); // timerender calls setInterval when imported rewiremock("../../static/js/timerender").with({ render_date(time1, time2) { @@ -45,10 +43,8 @@ rewiremock("../../static/js/rows").with({ }, }); -rewiremock.enable(); - -const {Filter} = zrequire("Filter", "js/filter"); -const {MessageListView} = zrequire("MessageListView", "js/message_list_view"); +const {Filter} = zrequire("../js/filter"); +const {MessageListView} = zrequire("../js/message_list_view"); const message_list = zrequire("message_list"); let next_timestamp = 1500000000; @@ -545,4 +541,3 @@ run_test("render_windows", () => { verify_move(197, [0, 400]); verify_no_move_range(0, 350); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/message_store.js b/frontend_tests/node_tests/message_store.js index 4a589bfddb..3710b43223 100644 --- a/frontend_tests/node_tests/message_store.js +++ b/frontend_tests/node_tests/message_store.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, with_field, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, with_field, zrequire} = require("../zjsunit/namespace"); const {make_stub} = require("../zjsunit/stub"); const {run_test} = require("../zjsunit/test"); @@ -25,8 +23,6 @@ set_global("page_params", { is_admin: true, }); -rewiremock.enable(); - const util = zrequire("util"); const people = zrequire("people"); const pm_conversations = zrequire("pm_conversations"); @@ -343,7 +339,6 @@ run_test("message_id_change", () => { }, }); - rewiremock("../../static/js/message_list").with({}); set_global("home_msg_list", {}); const opts = { @@ -377,4 +372,3 @@ run_test("errors", () => { blueslip.expect("error", "message_store.get got bad value: undefined"); message_store.get(undefined); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/narrow.js b/frontend_tests/node_tests/narrow.js index 9445a0954b..96715dfa07 100644 --- a/frontend_tests/node_tests/narrow.js +++ b/frontend_tests/node_tests/narrow.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, with_field, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, with_field, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -12,16 +10,15 @@ set_global("page_params", { stop_words: ["what", "about"], }); -rewiremock.enable(); +const stream_topic_history = {__esModule: true}; +rewiremock("../../static/js/stream_topic_history").with(stream_topic_history); const hash_util = zrequire("hash_util"); const compose_state = zrequire("compose_state"); const narrow_state = zrequire("narrow_state"); const people = zrequire("people"); const stream_data = zrequire("stream_data"); -const stream_topic_history = {__esModule: true}; -rewiremock("../../static/js/stream_topic_history").with(stream_topic_history); -const {Filter} = zrequire("Filter", "js/filter"); +const {Filter} = zrequire("../js/filter"); const narrow = zrequire("narrow"); function set_filter(operators) { @@ -372,4 +369,3 @@ run_test("narrow_to_compose_target PMs", (override) => { assert.equal(args.called, true); assert.deepEqual(args.operators, [{operator: "is", operand: "private"}]); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/narrow_activate.js b/frontend_tests/node_tests/narrow_activate.js index b3f57eab6f..4e4ebea83c 100644 --- a/frontend_tests/node_tests/narrow_activate.js +++ b/frontend_tests/node_tests/narrow_activate.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); rewiremock("../../static/js/resize").with({ @@ -67,8 +65,6 @@ rewiremock("../../static/js/muting").with({ is_topic_muted: () => false, }); -rewiremock.enable(); - const util = zrequire("util"); const narrow_state = zrequire("narrow_state"); const stream_data = zrequire("stream_data"); @@ -245,4 +241,3 @@ run_test("basics", () => { cont(); helper.assert_events(["report narrow times"]); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/narrow_local.js b/frontend_tests/node_tests/narrow_local.js index 4455f73690..b9ee899c08 100644 --- a/frontend_tests/node_tests/narrow_local.js +++ b/frontend_tests/node_tests/narrow_local.js @@ -2,18 +2,15 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {zrequire} = require("../zjsunit/namespace"); +const {rewiremock, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const message_list = {__esModule: true}; rewiremock("../../static/js/message_list").with(message_list); -rewiremock.enable(); -const {Filter} = zrequire("Filter", "js/filter"); -const {MessageListData} = zrequire("MessageListData", "js/message_list_data"); +const {Filter} = zrequire("../js/filter"); +const {MessageListData} = zrequire("../js/message_list_data"); const narrow_state = zrequire("narrow_state"); const narrow = zrequire("narrow"); @@ -450,4 +447,3 @@ run_test("final corner case", () => { test_with(fixture); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/narrow_state.js b/frontend_tests/node_tests/narrow_state.js index 101de7755e..2c2bf59099 100644 --- a/frontend_tests/node_tests/narrow_state.js +++ b/frontend_tests/node_tests/narrow_state.js @@ -8,7 +8,7 @@ const {run_test} = require("../zjsunit/test"); set_global("page_params", {}); const people = zrequire("people"); -const {Filter} = zrequire("Filter", "js/filter"); +const {Filter} = zrequire("../js/filter"); const stream_data = zrequire("stream_data"); const narrow_state = zrequire("narrow_state"); diff --git a/frontend_tests/node_tests/narrow_unread.js b/frontend_tests/node_tests/narrow_unread.js index 982d7628e8..681d0a1636 100644 --- a/frontend_tests/node_tests/narrow_unread.js +++ b/frontend_tests/node_tests/narrow_unread.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const message_store = {__esModule: true}; @@ -15,9 +13,7 @@ rewiremock("../../static/js/muting").with({ is_topic_muted: () => false, }); -rewiremock.enable(); - -const {Filter} = zrequire("Filter", "js/filter"); +const {Filter} = zrequire("../js/filter"); const people = zrequire("people"); const stream_data = zrequire("stream_data"); const unread = zrequire("unread"); @@ -212,4 +208,3 @@ run_test("defensive code", () => { flavor: "cannot_compute", }); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/password.js b/frontend_tests/node_tests/password.js index 72310938b3..103c9877dc 100644 --- a/frontend_tests/node_tests/password.js +++ b/frontend_tests/node_tests/password.js @@ -5,7 +5,8 @@ const {strict: assert} = require("assert"); const {set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); -set_global("zxcvbn", zrequire("zxcvbn", "zxcvbn")); +set_global("zxcvbn", require("zxcvbn")); + const common = zrequire("common"); run_test("basics", () => { diff --git a/frontend_tests/node_tests/people.js b/frontend_tests/node_tests/people.js index f41bcd3297..7a0fc9a363 100644 --- a/frontend_tests/node_tests/people.js +++ b/frontend_tests/node_tests/people.js @@ -5,17 +5,14 @@ const {strict: assert} = require("assert"); const {parseISO} = require("date-fns"); const _ = require("lodash"); const MockDate = require("mockdate"); -const rewiremock = require("rewiremock/node"); -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const message_store = {__esModule: true}; rewiremock("../../static/js/message_store").with(message_store); const page_params = set_global("page_params", {}); -rewiremock.enable(); - const people = zrequire("people"); const settings_config = zrequire("settings_config"); const visibility = settings_config.email_address_visibility_values; @@ -1117,4 +1114,3 @@ run_test("get_active_message_people", () => { // reset to native Date() MockDate.reset(); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/people_errors.js b/frontend_tests/node_tests/people_errors.js index 5e8c5e7cb2..3f7ccabda2 100644 --- a/frontend_tests/node_tests/people_errors.js +++ b/frontend_tests/node_tests/people_errors.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {zrequire} = require("../zjsunit/namespace"); +const {rewiremock, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const reload_state = { @@ -13,7 +11,6 @@ const reload_state = { }; rewiremock("../../static/js/reload_state").with(reload_state); -rewiremock.enable(); const people = zrequire("people"); @@ -121,4 +118,3 @@ run_test("blueslip", () => { blueslip.expect("error", "Trying to set undefined field id"); people.set_custom_profile_field_data(maria.user_id, {}); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/pm_list.js b/frontend_tests/node_tests/pm_list.js index 177aa7d00c..519789c78f 100644 --- a/frontend_tests/node_tests/pm_list.js +++ b/frontend_tests/node_tests/pm_list.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {with_field, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, with_field, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -29,8 +27,6 @@ const pm_list_dom = {__esModule: true}; rewiremock("../../static/js/pm_list_dom").with(pm_list_dom); -rewiremock.enable(); - const people = zrequire("people"); const pm_conversations = zrequire("pm_conversations"); const pm_list = zrequire("pm_list"); @@ -296,4 +292,3 @@ run_test("ensure coverage", (override) => { }, ); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/popovers.js b/frontend_tests/node_tests/popovers.js index c3b11be43b..40b14c7447 100644 --- a/frontend_tests/node_tests/popovers.js +++ b/frontend_tests/node_tests/popovers.js @@ -2,10 +2,8 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - const {stub_templates} = require("../zjsunit/handlebars"); -const {set_global, with_field, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, with_field, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -41,11 +39,6 @@ const stream_data = {__esModule: true}; rewiremock("../../static/js/stream_data").with(stream_data); -const ClipboardJS = noop; -rewiremock("clipboard").with(ClipboardJS); - -rewiremock.enable(); - const people = zrequire("people"); const user_status = zrequire("user_status"); const message_edit = zrequire("message_edit"); @@ -53,6 +46,8 @@ const message_edit = zrequire("message_edit"); // Bypass some scary code that runs when we import the module. const popovers = with_field($.fn, "popover", noop, () => zrequire("popovers")); +popovers.__Rewire__("ClipboardJS", noop); + const alice = { email: "alice@example.com", full_name: "Alice Smith", @@ -264,5 +259,3 @@ test_ui("actions_popover", (override) => { handler.call(target, e); }); - -rewiremock.disable(); diff --git a/frontend_tests/node_tests/presence.js b/frontend_tests/node_tests/presence.js index 1b9eb02025..b52037c16c 100644 --- a/frontend_tests/node_tests/presence.js +++ b/frontend_tests/node_tests/presence.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {zrequire} = require("../zjsunit/namespace"); +const {rewiremock, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const server_events = {__esModule: true}; @@ -15,7 +13,6 @@ const reload_state = { }; rewiremock("../../static/js/reload_state").with(reload_state); -rewiremock.enable(); const people = zrequire("people"); const presence = zrequire("presence"); @@ -333,4 +330,3 @@ run_test("update_info_from_event", () => { last_active: 1000, }); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/reactions.js b/frontend_tests/node_tests/reactions.js index 1277857f89..8a74f56adb 100644 --- a/frontend_tests/node_tests/reactions.js +++ b/frontend_tests/node_tests/reactions.js @@ -2,10 +2,8 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - const {stub_templates} = require("../zjsunit/handlebars"); -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {make_stub} = require("../zjsunit/stub"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -80,10 +78,8 @@ set_global("current_msg_list", { }, }); -rewiremock.enable(); - -const emoji_codes = zrequire("emoji_codes", "generated/emoji/emoji_codes.json"); -const emoji = zrequire("emoji", "shared/js/emoji"); +const emoji_codes = zrequire("../generated/emoji/emoji_codes.json"); +const emoji = zrequire("../shared/js/emoji"); const people = zrequire("people"); const reactions = zrequire("reactions"); @@ -996,4 +992,3 @@ run_test("process_reaction_click bad local id", (override) => { ); reactions.process_reaction_click("some-msg-id", "bad-local-id"); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/recent_senders.js b/frontend_tests/node_tests/recent_senders.js index 64b9484017..3f98529fba 100644 --- a/frontend_tests/node_tests/recent_senders.js +++ b/frontend_tests/node_tests/recent_senders.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {zrequire} = require("../zjsunit/namespace"); +const {rewiremock, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); let next_id = 0; @@ -25,8 +23,6 @@ const message_list = { rewiremock("../../static/js/message_list").with(message_list); -rewiremock.enable(); - const rs = zrequire("recent_senders"); zrequire("message_util.js"); @@ -228,4 +224,3 @@ run_test("process_message_for_senders", (override) => { // no changes should take place in this case. rs.update_topics_of_deleted_message_ids([-1]); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/recent_topics.js b/frontend_tests/node_tests/recent_topics.js index 8751925f92..eb71ab3834 100644 --- a/frontend_tests/node_tests/recent_topics.js +++ b/frontend_tests/node_tests/recent_topics.js @@ -2,10 +2,8 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - const {stub_templates} = require("../zjsunit/handlebars"); -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -169,8 +167,6 @@ rewiremock("../../static/js/stream_data").with({ id_is_subscribed: () => true, }); -rewiremock.enable(); - const people = zrequire("people"); const rt = zrequire("recent_topics"); @@ -819,4 +815,3 @@ run_test("test_search", () => { assert.equal(rt.topic_in_search_results("\\", "general", "\\"), true); assert.equal(rt.topic_in_search_results("\\", "general", "\\\\"), true); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/rendered_markdown.js b/frontend_tests/node_tests/rendered_markdown.js index 654f6f5b6c..aad0d07574 100644 --- a/frontend_tests/node_tests/rendered_markdown.js +++ b/frontend_tests/node_tests/rendered_markdown.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, with_field, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, with_field, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -13,8 +11,6 @@ rewiremock("../../static/js/rtl").with({ }); const page_params = set_global("page_params", {emojiset: "apple"}); -rewiremock.enable(); - const rm = zrequire("rendered_markdown"); const people = zrequire("people"); const user_groups = zrequire("user_groups"); @@ -273,4 +269,3 @@ run_test("spoiler-header-empty-fill", () => { rm.update_elements($content); assert.equal(toggle_button_html + "

translated: Spoiler

", $header.html()); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/scroll_util.js b/frontend_tests/node_tests/scroll_util.js index a97889e502..1c8d0544f2 100644 --- a/frontend_tests/node_tests/scroll_util.js +++ b/frontend_tests/node_tests/scroll_util.js @@ -2,17 +2,13 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {zrequire} = require("../zjsunit/namespace"); +const {rewiremock, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); rewiremock("../../static/js/ui").with({ get_scroll_element: (element) => element, }); -rewiremock.enable(); - const scroll_util = zrequire("scroll_util"); run_test("scroll_delta", () => { @@ -125,4 +121,3 @@ run_test("scroll_element_into_container", () => { scroll_util.scroll_element_into_container(elem2, container); assert.equal(container.scrollTop(), 250 - 100 + 3 + 15); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/search.js b/frontend_tests/node_tests/search.js index 81087375dd..ae873e80e0 100644 --- a/frontend_tests/node_tests/search.js +++ b/frontend_tests/node_tests/search.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -35,11 +33,9 @@ rewiremock("../../static/js/search_pill_widget").with({ set_global("setTimeout", (func) => func()); -rewiremock.enable(); - const search = zrequire("search"); const search_pill = zrequire("search_pill"); -const {Filter} = zrequire("Filter", "js/filter"); +const {Filter} = zrequire("../js/filter"); run_test("clear_search_form", () => { $("#search_query").val("noise"); @@ -350,4 +346,3 @@ run_test("initiate_search", () => { assert(is_searchbox_text_selected); assert(is_searchbox_focused); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/search_legacy.js b/frontend_tests/node_tests/search_legacy.js index 8c82787bfb..f13be34b25 100644 --- a/frontend_tests/node_tests/search_legacy.js +++ b/frontend_tests/node_tests/search_legacy.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -31,8 +29,6 @@ rewiremock("../../static/js/filter").with({ set_global("setTimeout", (func) => func()); -rewiremock.enable(); - const search = zrequire("search"); run_test("update_button_visibility", () => { @@ -303,4 +299,3 @@ run_test("initiate_search", () => { search.initiate_search(); assert.equal($("#search_query").val(), "ver "); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/search_suggestion.js b/frontend_tests/node_tests/search_suggestion.js index 3b37f2e355..5af228c1e7 100644 --- a/frontend_tests/node_tests/search_suggestion.js +++ b/frontend_tests/node_tests/search_suggestion.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const page_params = set_global("page_params", { @@ -15,10 +13,6 @@ rewiremock("../../static/js/message_store").with({ user_ids: () => [], }); -rewiremock("../../static/js/narrow").with({}); - -rewiremock.enable(); - const settings_config = zrequire("settings_config"); page_params.realm_email_address_visibility = settings_config.email_address_visibility_values.admins_only.code; @@ -969,4 +963,3 @@ run_test("multiple_operators_without_pills", () => { expected = ["is:alerted sender:ted@zulip.com abc"]; assert.deepEqual(suggestions.strings, expected); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/search_suggestion_legacy.js b/frontend_tests/node_tests/search_suggestion_legacy.js index 304b0a0a91..e306bea6a4 100644 --- a/frontend_tests/node_tests/search_suggestion_legacy.js +++ b/frontend_tests/node_tests/search_suggestion_legacy.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const page_params = set_global("page_params", { @@ -13,9 +11,6 @@ const page_params = set_global("page_params", { rewiremock("../../static/js/message_store").with({ user_ids: () => [], }); -rewiremock("../../static/js/narrow").with({}); - -rewiremock.enable(); const settings_config = zrequire("settings_config"); page_params.realm_email_address_visibility = @@ -887,4 +882,3 @@ run_test("queries_with_spaces", () => { expected = ["stream:offi", "stream:office"]; assert.deepEqual(suggestions.strings, expected); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/server_events.js b/frontend_tests/node_tests/server_events.js index 7557911af7..dcee8e523e 100644 --- a/frontend_tests/node_tests/server_events.js +++ b/frontend_tests/node_tests/server_events.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const noop = () => {}; @@ -45,10 +43,21 @@ rewiremock("../../static/js/ui_report").with({ }, }); -const message_events = {__esModule: true}; -rewiremock("../../static/js/message_events").with(message_events); +rewiremock("../../static/js/stream_events").with({ + update_property() { + throw new Error("subs update error"); + }, +}); -rewiremock.enable(); +const message_events = rewiremock("../../static/js/message_events").with({ + __esModule: true, + insert_new_messages() { + throw new Error("insert error"); + }, + update_messages() { + throw new Error("update error"); + }, +}); const server_events = zrequire("server_events"); @@ -77,17 +86,6 @@ run_test("message_event", (override) => { const setup = () => { server_events.home_view_loaded(); - message_events.insert_new_messages = () => { - throw new Error("insert error"); - }; - message_events.update_messages = () => { - throw new Error("update error"); - }; - rewiremock("../../static/js/stream_events").with({ - update_property() { - throw new Error("subs update error"); - }, - }); }; run_test("event_dispatch_error", () => { @@ -141,4 +139,3 @@ run_test("event_edit_message_error", () => { assert.equal(logs.length, 1); assert.equal(logs[0].more_info, undefined); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/settings_bots.js b/frontend_tests/node_tests/settings_bots.js index d9208d22bf..e4b29ef936 100644 --- a/frontend_tests/node_tests/settings_bots.js +++ b/frontend_tests/node_tests/settings_bots.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -30,19 +28,15 @@ const bot_data_params = { }; const avatar = {__esModule: true}; - rewiremock("../../static/js/avatar").with(avatar); function ClipboardJS(sel) { assert.equal(sel, "#copy_zuliprc"); } -rewiremock("clipboard").with(ClipboardJS); - -rewiremock.enable(); - const bot_data = zrequire("bot_data"); const settings_bots = zrequire("settings_bots"); +settings_bots.__Rewire__("ClipboardJS", ClipboardJS); bot_data.initialize(bot_data_params); @@ -201,5 +195,3 @@ run_test("can_create_new_bots", () => { page_params.realm_bot_creation_policy = 3; assert(!settings_bots.can_create_new_bots()); }); - -rewiremock.disable(); diff --git a/frontend_tests/node_tests/settings_emoji.js b/frontend_tests/node_tests/settings_emoji.js index 57380cbff7..56dff17f8a 100644 --- a/frontend_tests/node_tests/settings_emoji.js +++ b/frontend_tests/node_tests/settings_emoji.js @@ -2,15 +2,12 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {zrequire} = require("../zjsunit/namespace"); +const {rewiremock, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); const upload_widget = {__esModule: true}; rewiremock("../../static/js/upload_widget").with(upload_widget); -rewiremock.enable(); const settings_emoji = zrequire("settings_emoji"); run_test("build_emoji_upload_widget", () => { @@ -32,4 +29,3 @@ run_test("build_emoji_upload_widget", () => { settings_emoji.build_emoji_upload_widget(); assert(build_widget_stub); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/settings_muting.js b/frontend_tests/node_tests/settings_muting.js index 71dce741b9..d174612e0e 100644 --- a/frontend_tests/node_tests/settings_muting.js +++ b/frontend_tests/node_tests/settings_muting.js @@ -2,16 +2,13 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {zrequire} = require("../zjsunit/namespace"); +const {rewiremock, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); const muting_ui = {__esModule: true}; rewiremock("../../static/js/muting_ui").with(muting_ui); -rewiremock.enable(); const settings_muting = zrequire("settings_muting"); const stream_data = zrequire("stream_data"); @@ -92,4 +89,3 @@ run_test("reset", () => { settings_muting.reset(); assert.equal(settings_muting.loaded, false); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/settings_org.js b/frontend_tests/node_tests/settings_org.js index 31f81c0d66..88494974c0 100644 --- a/frontend_tests/node_tests/settings_org.js +++ b/frontend_tests/node_tests/settings_org.js @@ -2,10 +2,8 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - const {stub_templates} = require("../zjsunit/handlebars"); -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -82,8 +80,6 @@ rewiremock("../../static/js/loading").with(_loading); rewiremock("../../static/js/ui_report").with(_ui_report); rewiremock("../../static/js/list_widget").with(_ListWidget); -rewiremock.enable(); - const settings_config = zrequire("settings_config"); const settings_bots = zrequire("settings_bots"); const stream_data = zrequire("stream_data"); @@ -1053,5 +1049,3 @@ run_test("misc", () => { assert.equal(elem.text(), "translated: Disabled"); assert(elem.hasClass("text-warning")); }); - -rewiremock.disable(); diff --git a/frontend_tests/node_tests/settings_profile_fields.js b/frontend_tests/node_tests/settings_profile_fields.js index 004b8bd791..8b55eef033 100644 --- a/frontend_tests/node_tests/settings_profile_fields.js +++ b/frontend_tests/node_tests/settings_profile_fields.js @@ -2,10 +2,8 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - const {stub_templates} = require("../zjsunit/handlebars"); -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -187,5 +185,3 @@ run_test("populate_profile_fields", (override) => { is_admin: true, }); }); - -rewiremock.disable(); diff --git a/frontend_tests/node_tests/settings_user_groups.js b/frontend_tests/node_tests/settings_user_groups.js index d520e8765d..8be547b8d1 100644 --- a/frontend_tests/node_tests/settings_user_groups.js +++ b/frontend_tests/node_tests/settings_user_groups.js @@ -3,10 +3,9 @@ const {strict: assert} = require("assert"); const _ = require("lodash"); -const rewiremock = require("rewiremock/node"); const {stub_templates} = require("../zjsunit/handlebars"); -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -42,8 +41,6 @@ const input_pill = {__esModule: true}; rewiremock("../../static/js/input_pill").with(input_pill); -rewiremock.enable(); - const user_pill = zrequire("user_pill"); const settings_user_groups = zrequire("settings_user_groups"); const settings_config = zrequire("settings_config"); @@ -880,4 +877,3 @@ test_ui("on_events", () => { assert(api_endpoint_called); })(); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/stream_edit.js b/frontend_tests/node_tests/stream_edit.js index d69293ef73..b4771124c9 100644 --- a/frontend_tests/node_tests/stream_edit.js +++ b/frontend_tests/node_tests/stream_edit.js @@ -2,10 +2,8 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - const {stub_templates} = require("../zjsunit/handlebars"); -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -36,8 +34,6 @@ const ui = { rewiremock("../../static/js/ui").with(ui); -rewiremock.enable(); - const peer_data = zrequire("peer_data"); const people = zrequire("people"); const stream_edit = zrequire("stream_edit"); @@ -275,4 +271,3 @@ test_ui("subscriber_pills", () => { expected_user_ids = potential_denmark_stream_subscribers.concat(fred.user_id); add_subscribers_handler(event); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/stream_events.js b/frontend_tests/node_tests/stream_events.js index a71744587d..1c8cea698c 100644 --- a/frontend_tests/node_tests/stream_events.js +++ b/frontend_tests/node_tests/stream_events.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {make_stub} = require("../zjsunit/stub"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -46,13 +44,11 @@ const subs = { rewiremock("../../static/js/subs").with(subs); rewiremock("../../static/js/overlays").with({streams_open: () => true}); -rewiremock.enable(); - const peer_data = zrequire("peer_data"); const people = zrequire("people"); const stream_data = zrequire("stream_data"); const stream_events = zrequire("stream_events"); -const {Filter} = zrequire("Filter", "js/filter"); +const {Filter} = zrequire("../js/filter"); const narrow_state = zrequire("narrow_state"); const message_view_header = zrequire("message_view_header"); @@ -410,4 +406,3 @@ run_test("remove_deactivated_user_from_all_streams", () => { // verify that we issue a call to update subscriber count/list UI assert.equal(subs_stub.num_calls, 1); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/stream_list.js b/frontend_tests/node_tests/stream_list.js index 938d9e2e9d..94cf2753a3 100644 --- a/frontend_tests/node_tests/stream_list.js +++ b/frontend_tests/node_tests/stream_list.js @@ -2,10 +2,8 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - const {stub_templates} = require("../zjsunit/handlebars"); -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -25,16 +23,17 @@ rewiremock("../../static/js/keydown_util").with({ handle: noop, }); -rewiremock.enable(); +rewiremock("../../static/js/ui").with({get_scroll_element: (element) => element}); -const {Filter} = zrequire("Filter", "js/filter"); +const narrow_state = rewiremock("../../static/js/narrow_state").with({__esModule: true}); + +const {Filter} = zrequire("../js/filter"); const stream_sort = zrequire("stream_sort"); const stream_color = zrequire("stream_color"); const unread = zrequire("unread"); const stream_data = zrequire("stream_data"); const scroll_util = zrequire("scroll_util"); const stream_list = zrequire("stream_list"); -rewiremock("../../static/js/ui").with({get_scroll_element: (element) => element}); stream_color.initialize(); @@ -376,17 +375,9 @@ test_ui("zoom_in_and_zoom_out", () => { assert($("#streams_list").hasClass("zoom-out")); }); -let narrow_state; test_ui("narrowing", () => { initialize_stream_data(); - narrow_state = rewiremock("../../static/js/narrow_state").with({ - stream() { - return "devel"; - }, - topic: noop, - }).mock.value; - topic_list.close = noop; topic_list.rebuild = noop; topic_list.active_stream_id = noop; @@ -744,4 +735,3 @@ test_ui("create_initial_sidebar_rows", () => { assert.equal(html_dict.get(1000), "
stub-html-devel"); assert.equal(html_dict.get(5000), "
stub-html-Denmark"); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/stream_search.js b/frontend_tests/node_tests/stream_search.js index 7e3c662715..b9123fca63 100644 --- a/frontend_tests/node_tests/stream_search.js +++ b/frontend_tests/node_tests/stream_search.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {zrequire} = require("../zjsunit/namespace"); +const {rewiremock, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -24,8 +22,6 @@ const stream_popover = {__esModule: true}; rewiremock("../../static/js/stream_popover").with(stream_popover); -rewiremock.enable(); - const stream_list = zrequire("stream_list"); function expand_sidebar() { @@ -196,4 +192,3 @@ run_test("expanding_sidebar", () => { assert.deepEqual(events, ["popovers.hide_all", "stream_popover.show_streamlist_sidebar"]); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/stream_topic_history.js b/frontend_tests/node_tests/stream_topic_history.js index f76026bfed..b778c025f5 100644 --- a/frontend_tests/node_tests/stream_topic_history.js +++ b/frontend_tests/node_tests/stream_topic_history.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {zrequire} = require("../zjsunit/namespace"); +const {rewiremock, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const channel = {__esModule: true}; @@ -14,8 +12,6 @@ rewiremock("../../static/js/message_list").with(message_list); const message_util = {__esModule: true}; rewiremock("../../static/js/message_util").with(message_util); -rewiremock.enable(); - const unread = zrequire("unread"); const stream_data = zrequire("stream_data"); const stream_topic_history = zrequire("stream_topic_history"); @@ -335,4 +331,3 @@ run_test("server_history_end_to_end", () => { }); assert(on_success_called); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/submessage.js b/frontend_tests/node_tests/submessage.js index 5bfa6a3239..41c24e3af7 100644 --- a/frontend_tests/node_tests/submessage.js +++ b/frontend_tests/node_tests/submessage.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {zrequire} = require("../zjsunit/namespace"); +const {rewiremock, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const channel = {__esModule: true}; @@ -15,8 +13,6 @@ const message_store = {__esModule: true}; rewiremock("../../static/js/message_store").with(message_store); -rewiremock.enable(); - const submessage = zrequire("submessage"); run_test("get_message_events", () => { @@ -107,4 +103,3 @@ run_test("handle_event", () => { assert.deepEqual(message.submessages[0], event); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/subs.js b/frontend_tests/node_tests/subs.js index d47bccb68a..ab1879441f 100644 --- a/frontend_tests/node_tests/subs.js +++ b/frontend_tests/node_tests/subs.js @@ -2,10 +2,8 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - const {stub_templates} = require("../zjsunit/handlebars"); -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -27,8 +25,6 @@ rewiremock("../../static/js/hash_util").with({ by_stream_uri: () => {}, }); -rewiremock.enable(); - const stream_data = zrequire("stream_data"); const subs = zrequire("subs"); @@ -211,4 +207,3 @@ run_test("redraw_left_panel", (override) => { assert(!$(".right .settings").visible()); assert($(".nothing-selected").visible()); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/support.js b/frontend_tests/node_tests/support.js index 86ae2c3bdc..f28f97fbe5 100644 --- a/frontend_tests/node_tests/support.js +++ b/frontend_tests/node_tests/support.js @@ -14,7 +14,7 @@ const dom = new JSDOM(template, {pretendToBeVisual: true}); const document = dom.window.document; run_test("scrub_realm", () => { - zrequire("support", "js/analytics/support"); + zrequire("../js/analytics/support"); const click_handler = $("body").get_on_handler("click", ".scrub-realm-button"); const fake_this = $.create("fake-.scrub-realm-button"); diff --git a/frontend_tests/node_tests/top_left_corner.js b/frontend_tests/node_tests/top_left_corner.js index bacc4cecde..af0f985f8e 100644 --- a/frontend_tests/node_tests/top_left_corner.js +++ b/frontend_tests/node_tests/top_left_corner.js @@ -2,34 +2,30 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); rewiremock("../../static/js/resize").with({ resize_stream_filters_container: () => {}, }); -rewiremock.enable(); -const {Filter} = zrequire("Filter", "js/filter"); +const {Filter} = zrequire("../js/filter"); const people = zrequire("people"); +const pm_list = zrequire("pm_list"); const top_left_corner = zrequire("top_left_corner"); -run_test("narrowing", () => { +run_test("narrowing", (override) => { // activating narrow let pm_expanded; let pm_closed; - rewiremock("../../static/js/pm_list").with({ - close() { - pm_closed = true; - }, - expand() { - pm_expanded = true; - }, + override(pm_list, "close", () => { + pm_closed = true; + }); + override(pm_list, "expand", () => { + pm_expanded = true; }); assert(!pm_expanded); @@ -138,4 +134,3 @@ run_test("update_count_in_dom", () => { assert.equal($("").text(), ""); assert.equal($("").text(), ""); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/topic_list_data.js b/frontend_tests/node_tests/topic_list_data.js index e17bd8f3be..46c4770bd6 100644 --- a/frontend_tests/node_tests/topic_list_data.js +++ b/frontend_tests/node_tests/topic_list_data.js @@ -3,9 +3,8 @@ const {strict: assert} = require("assert"); const _ = require("lodash"); -const rewiremock = require("rewiremock/node"); -const {zrequire} = require("../zjsunit/namespace"); +const {rewiremock, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const narrow_state = { @@ -21,9 +20,6 @@ const muting = { }, }; rewiremock("../../static/js/muting").with(muting); -rewiremock("../../static/js/message_list").with({}); - -rewiremock.enable(); const stream_data = zrequire("stream_data"); const unread = zrequire("unread"); @@ -152,4 +148,3 @@ run_test("get_list_info unreads", (override) => { ["topic 0", "topic 1", "topic 2", "topic 3", "topic 5", "topic 6", "topic 7", "topic 8"], ); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/transmit.js b/frontend_tests/node_tests/transmit.js index 82c1d4feed..93385b8664 100644 --- a/frontend_tests/node_tests/transmit.js +++ b/frontend_tests/node_tests/transmit.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const noop = () => {}; @@ -24,8 +22,6 @@ const sent_messages = { rewiremock("../../static/js/sent_messages").with(sent_messages); -rewiremock.enable(); - const people = zrequire("people"); const transmit = zrequire("transmit"); @@ -197,4 +193,3 @@ run_test("reply_message_errors", () => { message: bogus_message, }); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/tutorial.js b/frontend_tests/node_tests/tutorial.js index e477ecd29d..7d7ceb7b77 100644 --- a/frontend_tests/node_tests/tutorial.js +++ b/frontend_tests/node_tests/tutorial.js @@ -9,9 +9,7 @@ // become clear as you keep reading. const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, with_field, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, with_field, zrequire} = require("../zjsunit/namespace"); const {make_stub} = require("../zjsunit/stub"); const {run_test} = require("../zjsunit/test"); @@ -54,8 +52,6 @@ const topic_list = {__esModule: true}; rewiremock("../../static/js/topic_list").with(topic_list); -rewiremock.enable(); - // Let's start with testing a function from util.js. // // We will use our special zrequire helper to import the @@ -197,7 +193,7 @@ run_test("unread", () => { // We use the second argument of zrequire to find the location of the // Filter class. -const {Filter} = zrequire("Filter", "js/filter"); +const {Filter} = zrequire("../js/filter"); run_test("filter", () => { const filter_terms = [ @@ -599,7 +595,6 @@ run_test("explore make_stub", (override) => { */ -rewiremock("../../static/js/unread_ops").disable(); unread_ops = zrequire("unread_ops"); run_test("unread_ops", (override) => { @@ -698,7 +693,6 @@ run_test("unread_ops", (override) => { */ -rewiremock("../../static/js/stream_list").disable(); stream_list = zrequire("stream_list"); const social_stream = { @@ -835,4 +829,3 @@ run_test("stream_list", (override) => { sidebar_helper.verify_actions(); topic_list_helper.verify_actions(); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/typeahead.js b/frontend_tests/node_tests/typeahead.js index 911bc5d9d4..6cca3f9ce7 100644 --- a/frontend_tests/node_tests/typeahead.js +++ b/frontend_tests/node_tests/typeahead.js @@ -5,7 +5,7 @@ const {strict: assert} = require("assert"); const {zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); -const typeahead = zrequire("typeahead", "shared/js/typeahead"); +const typeahead = zrequire("../shared/js/typeahead"); // The data structures here may be different for // different apps; the only key thing is we look diff --git a/frontend_tests/node_tests/typeahead_helper.js b/frontend_tests/node_tests/typeahead_helper.js index 573e25e529..4643e2b510 100644 --- a/frontend_tests/node_tests/typeahead_helper.js +++ b/frontend_tests/node_tests/typeahead_helper.js @@ -24,8 +24,8 @@ zrequire("presence"); zrequire("buddy_data"); zrequire("hash_util"); -const emoji = zrequire("emoji", "shared/js/emoji"); -const pygments_data = zrequire("pygments_data", "generated/pygments_data.json"); +const emoji = zrequire("../shared/js/emoji"); +const pygments_data = zrequire("../generated/pygments_data.json"); const actual_pygments_data = {...pygments_data}; const ct = zrequire("composebox_typeahead"); const th = zrequire("typeahead_helper"); diff --git a/frontend_tests/node_tests/typing_status.js b/frontend_tests/node_tests/typing_status.js index d31602e60e..fb6f45bc78 100644 --- a/frontend_tests/node_tests/typing_status.js +++ b/frontend_tests/node_tests/typing_status.js @@ -7,7 +7,7 @@ const {run_test} = require("../zjsunit/test"); const typing = zrequire("typing"); const compose_pm_pill = zrequire("compose_pm_pill"); -const typing_status = zrequire("typing_status", "shared/js/typing_status"); +const typing_status = zrequire("../shared/js/typing_status"); function make_time(secs) { // make times semi-realistic diff --git a/frontend_tests/node_tests/unread.js b/frontend_tests/node_tests/unread.js index e9da94c976..edadf3152b 100644 --- a/frontend_tests/node_tests/unread.js +++ b/frontend_tests/node_tests/unread.js @@ -3,9 +3,8 @@ const {strict: assert} = require("assert"); const _ = require("lodash"); -const rewiremock = require("rewiremock/node"); -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); let page_params = set_global("page_params", { @@ -18,8 +17,6 @@ const message_store = {__esModule: true}; rewiremock("../../static/js/message_store").with(message_store); -rewiremock.enable(); - const muting = zrequire("muting"); const people = zrequire("people"); const stream_data = zrequire("stream_data"); @@ -696,4 +693,3 @@ run_test("errors", () => { assert.equal(counts.private_message_count, 0); test_notifiable_count(counts.home_unread_messages, 0); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/upgrade.js b/frontend_tests/node_tests/upgrade.js index 306563197e..83840483e9 100644 --- a/frontend_tests/node_tests/upgrade.js +++ b/frontend_tests/node_tests/upgrade.js @@ -25,7 +25,7 @@ set_global("page_params", { percent_off: 20, }); -const helpers = zrequire("helpers", "js/billing/helpers"); +const helpers = zrequire("../js/billing/helpers"); run_test("initialize", () => { let token_func; @@ -101,7 +101,7 @@ run_test("initialize", () => { $("#autopay-form").data = (key) => document.querySelector("#autopay-form").getAttribute("data-" + key); - zrequire("upgrade", "js/billing/upgrade"); + zrequire("../js/billing/upgrade"); const e = { preventDefault: noop, diff --git a/frontend_tests/node_tests/upload.js b/frontend_tests/node_tests/upload.js index 276c7ffffa..479d7e350e 100644 --- a/frontend_tests/node_tests/upload.js +++ b/frontend_tests/node_tests/upload.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {reset_module, set_global, zrequire} = require("../zjsunit/namespace"); +const {set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -33,7 +31,11 @@ const plugin_stub = { }, }; -let upload = zrequire("upload"); +const upload = zrequire("upload"); + +// Even though we stub out Uppy, we need to reference it +// for line coverage purposes. +assert(upload.__get__("Uppy")); run_test("feature_check", (override) => { const upload_button = $.create("upload-button-stub"); @@ -323,8 +325,6 @@ run_test("upload_files", () => { assert($("#compose-textarea").val(), "user modified text"); }); -rewiremock.enable(); - run_test("uppy_config", () => { let uppy_stub_called = false; let uppy_set_meta_called = false; @@ -367,8 +367,7 @@ run_test("uppy_config", () => { }; } uppy_stub.Plugin = plugin_stub; - rewiremock("@uppy/core").with(uppy_stub); - upload = reset_module("upload"); + upload.__Rewire__("Uppy", uppy_stub); upload.setup_upload({mode: "compose"}); assert.equal(uppy_stub_called, true); @@ -505,8 +504,7 @@ run_test("uppy_events", () => { }; } uppy_stub.Plugin = plugin_stub; - rewiremock("@uppy/core").with(uppy_stub); - upload = reset_module("upload"); + upload.__Rewire__("Uppy", uppy_stub); upload.setup_upload({mode: "compose"}); assert.equal(Object.keys(callbacks).length, 5); @@ -692,5 +690,3 @@ run_test("uppy_events", () => { assert(compose_ui_replace_syntax_called); assert.equal($("#compose-textarea").val(), "user modified text"); }); - -rewiremock.disable(); diff --git a/frontend_tests/node_tests/user_events.js b/frontend_tests/node_tests/user_events.js index 62967ea579..715ed452e8 100644 --- a/frontend_tests/node_tests/user_events.js +++ b/frontend_tests/node_tests/user_events.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); rewiremock("../../static/js/activity").with({ @@ -58,8 +56,6 @@ const message_live_update = {__esModule: true}; rewiremock("../../static/js/message_live_update").with(message_live_update); -rewiremock.enable(); - const people = zrequire("people"); const settings_config = zrequire("settings_config"); const user_events = zrequire("user_events"); @@ -216,4 +212,3 @@ run_test("updates", () => { person = people.get_by_email(test_bot.email); assert.equal(person.bot_owner_id, me.user_id); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/user_status.js b/frontend_tests/node_tests/user_status.js index f323637ab1..bb1ee6d1d3 100644 --- a/frontend_tests/node_tests/user_status.js +++ b/frontend_tests/node_tests/user_status.js @@ -2,14 +2,11 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {zrequire} = require("../zjsunit/namespace"); +const {rewiremock, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const channel = {__esModule: true}; rewiremock("../../static/js/channel").with(channel); -rewiremock.enable(); const user_status = zrequire("user_status"); function initialize() { @@ -87,4 +84,3 @@ run_test("defensive checks", () => { user_status.set_away("string"); user_status.revoke_away("string"); }); -rewiremock.disable(); diff --git a/frontend_tests/node_tests/widgetize.js b/frontend_tests/node_tests/widgetize.js index b09a373e2b..ab3750fe29 100644 --- a/frontend_tests/node_tests/widgetize.js +++ b/frontend_tests/node_tests/widgetize.js @@ -2,9 +2,7 @@ const {strict: assert} = require("assert"); -const rewiremock = require("rewiremock/node"); - -const {set_global, zrequire} = require("../zjsunit/namespace"); +const {rewiremock, set_global, zrequire} = require("../zjsunit/namespace"); const {run_test} = require("../zjsunit/test"); const $ = require("../zjsunit/zjquery"); @@ -58,8 +56,6 @@ const narrow_state = {__esModule: true}; rewiremock("../../static/js/narrow_state").with(narrow_state); set_global("current_msg_list", {}); -rewiremock.enable(); - const widgetize = zrequire("widgetize"); run_test("activate", (override) => { @@ -181,4 +177,3 @@ run_test("activate", (override) => { }); widgetize.set_widgets_for_list(); }); -rewiremock.disable(); diff --git a/frontend_tests/zjsunit/index.js b/frontend_tests/zjsunit/index.js index 8373f350f8..3bea5842c1 100644 --- a/frontend_tests/zjsunit/index.js +++ b/frontend_tests/zjsunit/index.js @@ -81,6 +81,7 @@ test.set_verbose(files.length === 1); try { for (const file of files) { + namespace.start(); namespace.set_global("window", window); namespace.set_global("to_$", () => window); namespace.set_global("location", { @@ -100,7 +101,7 @@ try { blueslip.reset(); } - namespace.restore(); + namespace.finish(); Handlebars.HandlebarsEnvironment.call(Handlebars); } } catch (error) { diff --git a/frontend_tests/zjsunit/namespace.js b/frontend_tests/zjsunit/namespace.js index eafe3a4bc2..3af1389a3e 100644 --- a/frontend_tests/zjsunit/namespace.js +++ b/frontend_tests/zjsunit/namespace.js @@ -1,10 +1,49 @@ "use strict"; +const actual_load = require("module")._load; const path = require("path"); const new_globals = new Set(); let old_globals = {}; +let objs_installed; +let mock_paths = {}; +let mocked_paths; +let mock_names; + +exports.start = () => { + objs_installed = false; + mock_paths = {}; + mocked_paths = new Set(); + mock_names = new Set(); +}; + +exports.rewiremock = (fn) => { + if (!fn.startsWith("../../static/js/")) { + throw new Error(`We only mock static/js files`); + } + const short_fn = fn.slice("../../static/js/".length); + const base_path = path.resolve("./static/js"); + const long_fn = path.join(base_path, short_fn); + + return { + with: (obj) => { + if (objs_installed) { + throw new Error(` + It is too late to install this mock. Consider instead: + + foo.__Rewire__(${short_fn}, ...) + + Or call this earlier. + `); + } + mock_paths[long_fn] = obj; + mock_names.add(short_fn); + return obj; + }, + }; +}; + exports.set_global = function (name, val) { if (val === null) { throw new Error(` @@ -22,31 +61,46 @@ exports.set_global = function (name, val) { return val; }; -function require_path(name, fn) { - if (fn === undefined) { - fn = "../../static/js/" + name; - } else if (/^generated\/|^js\/|^shared\/|^third\//.test(fn)) { - // FIXME: Stealing part of the NPM namespace is confusing. - fn = "../../static/" + fn; - } +exports.zrequire = function (fn) { + objs_installed = true; - return fn; -} + // Because we do lazy compilation, we don't reset the + // _load hook until our test runners calls `finish()`. + require("module")._load = (request, parent, isMain) => { + const long_fn = path.resolve(path.join(path.dirname(parent.filename), request)); + if (mock_paths[long_fn]) { + mocked_paths.add(long_fn); + return mock_paths[long_fn]; + } -exports.zrequire = function (name, fn) { - return require(require_path(name, fn)); -}; - -exports.reset_module = function (name, fn) { - fn = require_path(name, fn); - delete require.cache[require.resolve(fn)]; - return require(fn); + return actual_load(request, parent, isMain); + }; + const full_path = path.resolve(path.join("static/js", fn)); + return require(full_path); }; const staticPath = path.resolve(__dirname, "../../static") + path.sep; const templatesPath = staticPath + "templates" + path.sep; -exports.restore = function () { +exports.finish = function () { + /* + Handle cleanup tasks after we've run one module. + + Note that we currently do lazy compilation of modules, + so we need to wait till the module tests finish + running to do things like detecting pointless mocks + and resetting our _load hook. + */ + for (const fn of Object.keys(mock_paths)) { + if (!mocked_paths.has(fn)) { + throw new Error(` + You asked to mock ${fn} but we never + saw it during compilation. + `); + } + } + + require("module")._load = actual_load; for (const path of Object.keys(require.cache)) { if (path.startsWith(staticPath) && !path.startsWith(templatesPath)) { delete require.cache[path]; diff --git a/package.json b/package.json index decc48151a..8052a2ee19 100644 --- a/package.json +++ b/package.json @@ -102,7 +102,6 @@ "openapi-examples-validator": "^4.0.0", "prettier": "^2.0.5", "puppeteer": "^8.0.0", - "rewiremock": "^3.13.9", "source-map": "https://github.com/benthemonkey/source-map.git#d95423f77edef6cbb9e21d2d6014c7de85ae220a", "stylelint": "^13.0.0", "stylelint-config-prettier": "^8.0.2", diff --git a/version.py b/version.py index 75cdc80f7b..f55e9936c6 100644 --- a/version.py +++ b/version.py @@ -45,4 +45,4 @@ API_FEATURE_LEVEL = 40 # historical commits sharing the same major version, in which case a # minor version bump suffices. -PROVISION_VERSION = "131.1" +PROVISION_VERSION = "132.0" diff --git a/yarn.lock b/yarn.lock index f4f504550f..c115bf4d52 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2235,14 +2235,6 @@ babel-plugin-rewire-ts@^1.4.0: resolved "https://registry.yarnpkg.com/babel-plugin-rewire-ts/-/babel-plugin-rewire-ts-1.4.0.tgz#6c814d5aa3ef3d8c0d0c7a27891877fb28930e5b" integrity sha512-XVyyWMIx1fNSG42vbUaAro1LANLs/fBW6KurYaeoVjS2U8zLCaow7LKll6zjs1cwcqcbZK2v59zVouPs+JAqxw== -babel-runtime@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" - integrity sha1-llxwWGaOgrVde/4E/yM3vItWR/4= - dependencies: - core-js "^2.4.0" - regenerator-runtime "^0.11.0" - bail@^1.0.0: version "1.0.5" resolved "https://registry.yarnpkg.com/bail/-/bail-1.0.5.tgz#b6fa133404a392cbc1f8c4bf63f5953351e7a776" @@ -3285,11 +3277,6 @@ compare-cell@^1.0.0: resolved "https://registry.yarnpkg.com/compare-cell/-/compare-cell-1.0.0.tgz#a9eb708f6e0e41aef7aa566b130f1968dc9e1aaa" integrity sha1-qetwj24OQa73qlZrEw8ZaNyeGqo= -compare-module-exports@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/compare-module-exports/-/compare-module-exports-2.1.0.tgz#c4fcb8759e42fb19c52798c510d7f9206b81fa8e" - integrity sha512-3Lc0sTIuX1jmY2K2RrXRJOND6KsRTX2D4v3+eu1PDptsuJZVK4LZc852eZa9I+avj0NrUKlTNgqvccNOH6mbGg== - compare-oriented-cell@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/compare-oriented-cell/-/compare-oriented-cell-1.0.1.tgz#6a149feef9dfc4f8fc62358e51dd42effbbdc39e" @@ -3457,11 +3444,6 @@ core-js-compat@^3.8.1, core-js-compat@^3.9.0: browserslist "^4.16.3" semver "7.0.0" -core-js@^2.4.0: - version "2.6.12" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec" - integrity sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ== - core-js@^3.0.1, core-js@^3.6.5: version "3.9.1" resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.9.1.tgz#cec8de593db8eb2a85ffb0dbdeb312cb6e5460ae" @@ -7732,11 +7714,6 @@ locate-path@^5.0.0: dependencies: p-locate "^4.1.0" -lodash._reinterpolate@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" - integrity sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0= - lodash.clonedeep@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" @@ -7782,31 +7759,11 @@ lodash.merge@^4.6.2: resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== -lodash.some@^4.6.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/lodash.some/-/lodash.some-4.6.0.tgz#1bb9f314ef6b8baded13b549169b2a945eb68e4d" - integrity sha1-G7nzFO9ri63tE7VJFpsqlF62jk0= - lodash.sortby@^4.7.0: version "4.7.0" resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg= -lodash.template@^4.4.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-4.5.0.tgz#f976195cf3f347d0d5f52483569fe8031ccce8ab" - integrity sha512-84vYFxIkmidUiFxidA/KjjH9pAycqW+h980j7Fuz5qxRtO9pgB7MDFTdys1N7A5mcucRiDyEq4fusljItR1T/A== - dependencies: - lodash._reinterpolate "^3.0.0" - lodash.templatesettings "^4.0.0" - -lodash.templatesettings@^4.0.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/lodash.templatesettings/-/lodash.templatesettings-4.2.0.tgz#e481310f049d3cf6d47e912ad09313b154f0fb33" - integrity sha512-stgLz+i3Aa9mZgnjr/O+v9ruKZsPsndy7qPZOchbqk2cnTU1ZaldKK+v7m54WoKIyxiuMZTKT2H81F8BeAc3ZQ== - dependencies: - lodash._reinterpolate "^3.0.0" - lodash.throttle@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4" @@ -8621,7 +8578,7 @@ node-gyp@^7.1.2: tar "^6.0.2" which "^2.0.2" -"node-libs-browser@^1.0.0 || ^2.0.0", node-libs-browser@^2.1.0, node-libs-browser@^2.2.1: +"node-libs-browser@^1.0.0 || ^2.0.0", node-libs-browser@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/node-libs-browser/-/node-libs-browser-2.2.1.tgz#b64f513d18338625f90346d27b0d235e631f6425" integrity sha512-h/zcD8H9kaDZ9ALUWwlBUDo6TKF8a7qBSCSEGfjTVIYeqsioSKaAX+BN7NgiMGp6iSIXZ3PxgCu8KS3b71YK5Q== @@ -9331,7 +9288,7 @@ path-key@^3.1.0: resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== -path-parse@^1.0.5, path-parse@^1.0.6: +path-parse@^1.0.6: version "1.0.6" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== @@ -10477,11 +10434,6 @@ regenerate@^1.4.0: resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.2.tgz#b9346d8827e8f5a32f7ba29637d398b69014848a" integrity sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A== -regenerator-runtime@^0.11.0: - version "0.11.1" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" - integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg== - regenerator-runtime@^0.13.3, regenerator-runtime@^0.13.4: version "0.13.7" resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz#cac2dacc8a1ea675feaabaeb8ae833898ae46f55" @@ -10865,20 +10817,6 @@ reusify@^1.0.4: resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== -rewiremock@^3.13.9: - version "3.14.3" - resolved "https://registry.yarnpkg.com/rewiremock/-/rewiremock-3.14.3.tgz#8b42d2b79bb39e8da51cb89159061c2366ea6db3" - integrity sha512-6BaUGfp7NtxBjisxcGN73nNiA2fS2AwhEk/9DMUqxfv5v0aDM1wpOYpj5GSArqsJi07YCfLhkD8C74LAN7+FkQ== - dependencies: - babel-runtime "^6.26.0" - compare-module-exports "^2.1.0" - lodash.some "^4.6.0" - lodash.template "^4.4.0" - node-libs-browser "^2.1.0" - path-parse "^1.0.5" - wipe-node-cache "^2.1.2" - wipe-webpack-cache "^2.1.0" - rgb-regex@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/rgb-regex/-/rgb-regex-1.0.1.tgz#c0e0d6882df0e23be254a475e8edd41915feaeb1" @@ -13523,18 +13461,6 @@ winchan@^0.2.1: resolved "https://registry.yarnpkg.com/winchan/-/winchan-0.2.2.tgz#6766917b88e5e1cb75f455ffc7cc13f51e5c834e" integrity sha512-pvN+IFAbRP74n/6mc6phNyCH8oVkzXsto4KCHPJ2AScniAnA1AmeLI03I2BzjePpaClGSI4GUMowzsD3qz5PRQ== -wipe-node-cache@^2.1.0, wipe-node-cache@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/wipe-node-cache/-/wipe-node-cache-2.1.2.tgz#f5aef4bc4366866f89536f3352eb6b9deda53ca0" - integrity sha512-m7NXa8qSxBGMtdQilOu53ctMaIBXy93FOP04EC1Uf4bpsE+r+adfLKwIMIvGbABsznaSNxK/ErD4xXDyY5og9w== - -wipe-webpack-cache@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/wipe-webpack-cache/-/wipe-webpack-cache-2.1.0.tgz#bc26149f21cf1a3c34752997b96458b567d3e6a1" - integrity sha512-OXzQMGpA7MnQQ8AG+uMl5mWR2ezy6fw1+DMHY+wzYP1qkF1jrek87psLBmhZEj+er4efO/GD4R8jXWFierobaA== - dependencies: - wipe-node-cache "^2.1.0" - word-wrap@^1.2.3, word-wrap@~1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c"