Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
zjsunit: Prevent mocking functions with with_field_rewire.
Steve Howell047a119d4698
diff --git a/frontend_tests/zjsunit/namespace.js b/frontend_tests/zjsunit/namespace.jsindex 933effe0d6a..17c3cb6dea3 100644--- a/frontend_tests/zjsunit/namespace.js+++ b/frontend_tests/zjsunit/namespace.js@@ -347,6 +347,10 @@ exports.with_field_rewire = function (obj, field, val, f) {// as exporting a helper function for tests from the module// containing the function you need to mock.+ if (typeof val === "function") {+ throw new TypeError("Please try to avoid mocking here, or use override_rewire.");+ }+const old_val = field in obj ? obj[field] : obj.__GetDependency__(field);try {obj.__Rewire__(field, val);