Skip to content

Commit b8ec791

Browse files
authored
Don't call afterEach within beforeEach (microsoft#46963)
Otherwise, a new afterEach handler is added for each test case and the number of handlers run grows quadratically.
1 parent cdf12f9 commit b8ec791

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

src/testRunner/unittests/createMapShim.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ namespace ts {
130130
}
131131

132132
MapShim = ShimCollections.createMapShim(getIterator);
133-
afterEach(() => {
134-
MapShim = undefined!;
135-
});
133+
});
134+
afterEach(() => {
135+
MapShim = undefined!;
136136
});
137137

138138
it("iterates values in insertion order and handles changes with string keys", () => {

src/testRunner/unittests/createSetShim.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ namespace ts {
128128
}
129129

130130
SetShim = ShimCollections.createSetShim(getIterator);
131-
afterEach(() => {
132-
SetShim = undefined!;
133-
});
131+
});
132+
afterEach(() => {
133+
SetShim = undefined!;
134134
});
135135

136136
it("iterates values in insertion order and handles changes with string keys", () => {

src/testRunner/unittests/debugDeprecation.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
namespace ts {
22
describe("unittests:: debugDeprecation", () => {
3+
let loggingHost: LoggingHost | undefined;
34
beforeEach(() => {
4-
const loggingHost = Debug.loggingHost;
5-
afterEach(() => {
6-
Debug.loggingHost = loggingHost;
7-
});
5+
loggingHost = Debug.loggingHost;
6+
});
7+
afterEach(() => {
8+
Debug.loggingHost = loggingHost;
9+
loggingHost = undefined;
810
});
911
describe("deprecateFunction", () => {
1012
it("silent deprecation", () => {

0 commit comments

Comments
 (0)