mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 20:43:19 +08:00
DEV: Clear pretender request log between test runs (#14456)
Previously we would store every FakeRequest object for all tests, resulting in many hundreds/thousands of objects in the `handledRequests` array. This commit ensures all pretender state is reset between tests.
This commit is contained in:
parent
b609f6c11c
commit
928f102516
|
@ -1111,3 +1111,10 @@ export function applyDefaultHandlers(pretender) {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function resetPretender() {
|
||||
instance.handlers = [];
|
||||
instance.handledRequests = [];
|
||||
instance.unhandledRequests = [];
|
||||
instance.passthroughRequests = [];
|
||||
}
|
||||
|
|
|
@ -3,9 +3,10 @@ import {
|
|||
exists,
|
||||
resetSite,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import createPretender, {
|
||||
import pretender, {
|
||||
applyDefaultHandlers,
|
||||
pretenderHelpers,
|
||||
resetPretender,
|
||||
} from "discourse/tests/helpers/create-pretender";
|
||||
import {
|
||||
currentSettings,
|
||||
|
@ -244,8 +245,7 @@ function setupTestsCommon(application, container, config) {
|
|||
setupS3CDN(null, null);
|
||||
}
|
||||
|
||||
server = createPretender;
|
||||
server.handlers = [];
|
||||
server = pretender;
|
||||
applyDefaultHandlers(server);
|
||||
|
||||
server.prepareBody = function (body) {
|
||||
|
@ -307,6 +307,7 @@ function setupTestsCommon(application, container, config) {
|
|||
|
||||
QUnit.testDone(function () {
|
||||
sinon.restore();
|
||||
resetPretender();
|
||||
|
||||
// Destroy any modals
|
||||
$(".modal-backdrop").remove();
|
||||
|
|
Loading…
Reference in New Issue
Block a user