Skip to content

Commit

Permalink
Don't call afterEach within beforeEach (#46963)
Browse files Browse the repository at this point in the history
Otherwise, a new afterEach handler is added for each test case and the
number of handlers run grows quadratically.
  • Loading branch information
amcasey authored Nov 30, 2021
1 parent cdf12f9 commit b8ec791
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/testRunner/unittests/createMapShim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ namespace ts {
}

MapShim = ShimCollections.createMapShim(getIterator);
afterEach(() => {
MapShim = undefined!;
});
});
afterEach(() => {
MapShim = undefined!;
});

it("iterates values in insertion order and handles changes with string keys", () => {
Expand Down
6 changes: 3 additions & 3 deletions src/testRunner/unittests/createSetShim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ namespace ts {
}

SetShim = ShimCollections.createSetShim(getIterator);
afterEach(() => {
SetShim = undefined!;
});
});
afterEach(() => {
SetShim = undefined!;
});

it("iterates values in insertion order and handles changes with string keys", () => {
Expand Down
10 changes: 6 additions & 4 deletions src/testRunner/unittests/debugDeprecation.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
namespace ts {
describe("unittests:: debugDeprecation", () => {
let loggingHost: LoggingHost | undefined;
beforeEach(() => {
const loggingHost = Debug.loggingHost;
afterEach(() => {
Debug.loggingHost = loggingHost;
});
loggingHost = Debug.loggingHost;
});
afterEach(() => {
Debug.loggingHost = loggingHost;
loggingHost = undefined;
});
describe("deprecateFunction", () => {
it("silent deprecation", () => {
Expand Down

0 comments on commit b8ec791

Please sign in to comment.