mirror of
https://github.com/discourse/discourse.git
synced 2025-02-24 14:14:27 +08:00

This started out as a seemingly benign refactor to replace the `require` for `withPluginApi` to an actual import. However, it broke the test in seemingly random places. It turns out that in serveral places, we are calling `isTesting()` in module scope and assigning the result to a constant. For example we do that in the composer service to disable checking drafts when testing. This is problematic because `isTesting` doesn't really set until the `discourse-bootstrap` initializer is run, and so any modules that are evaluated before then will have locked in the wrong value for `isTesting()`. If we are going to use and treat `isTesting()` like a constant then we will have to make sure we set it sufficiently early before any code-loading happens.