mirror of https://github.com/zulip/zulip.git
305a1ac57d
There is good reason to do this (explanation is bit long!). With the TypeScript migration, and the require and ES6 migrations that come with it, we use require instead of set_global which loads the entire module. Suppose we have a util module, which is used by some other module, say message_store, and util is being required in message_store since it is removed from window. Then, if a test zrequires message_store first, and then zrequires the util module qand mocks one of its methods, it will not be mocked for the message_store module. The reason is: 1. zrequire('message_store') leads to require('util'). 2. zrequire('util') removes the util module from cache and it is reloaded. Now the util module in message_store and the one in the test will be different and any updates to it in tests won't be reflected in the actual code. Which can lead to confusion for folks writing tests. I'll mention this can be avoided doing zrequire('util') first but...that is not ideal. And, since there was one outlier test that relied on this behavior, we add the namespace.reset_module function. |
||
---|---|---|
.. | ||
finder.js | ||
handlebars.js | ||
i18n.js | ||
index.js | ||
markdown_assert.js | ||
mdiff.js | ||
namespace.js | ||
stub.js | ||
zblueslip.js | ||
zjquery.js |