mirror of
https://github.com/discourse/discourse.git
synced 2025-06-07 08:47:15 +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:
@ -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,
|
exists,
|
||||||
resetSite,
|
resetSite,
|
||||||
} from "discourse/tests/helpers/qunit-helpers";
|
} from "discourse/tests/helpers/qunit-helpers";
|
||||||
import createPretender, {
|
import pretender, {
|
||||||
applyDefaultHandlers,
|
applyDefaultHandlers,
|
||||||
pretenderHelpers,
|
pretenderHelpers,
|
||||||
|
resetPretender,
|
||||||
} from "discourse/tests/helpers/create-pretender";
|
} from "discourse/tests/helpers/create-pretender";
|
||||||
import {
|
import {
|
||||||
currentSettings,
|
currentSettings,
|
||||||
@ -244,8 +245,7 @@ function setupTestsCommon(application, container, config) {
|
|||||||
setupS3CDN(null, null);
|
setupS3CDN(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
server = createPretender;
|
server = pretender;
|
||||||
server.handlers = [];
|
|
||||||
applyDefaultHandlers(server);
|
applyDefaultHandlers(server);
|
||||||
|
|
||||||
server.prepareBody = function (body) {
|
server.prepareBody = function (body) {
|
||||||
@ -307,6 +307,7 @@ function setupTestsCommon(application, container, config) {
|
|||||||
|
|
||||||
QUnit.testDone(function () {
|
QUnit.testDone(function () {
|
||||||
sinon.restore();
|
sinon.restore();
|
||||||
|
resetPretender();
|
||||||
|
|
||||||
// Destroy any modals
|
// Destroy any modals
|
||||||
$(".modal-backdrop").remove();
|
$(".modal-backdrop").remove();
|
||||||
|
Reference in New Issue
Block a user