Skip to content

Commit 20fd33f

Browse files
alan-agius4clydin
authored andcommitted
feat(@schematics/angular): destroy test module after every test
In version 12.1, the framework added the `destroyAfterEach` an opt-in feature that improves tests performance and also addresses two long-standing issues. The idea, is to have this enabled by default in the future. Related PR: angular/angular#42566 Closes #21280
1 parent 5256699 commit 20fd33f

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

packages/angular_devkit/build_angular/test/hello-world-app/src/test.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ declare const require: {
2323
};
2424

2525
// First, initialize the Angular testing environment.
26-
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
26+
getTestBed().initTestEnvironment(
27+
BrowserDynamicTestingModule,
28+
platformBrowserDynamicTesting(),
29+
{ teardown: { destroyAfterEach: true }},
30+
);
2731
// Then we find all the tests.
2832
const context = require.context('./', true, /\.spec\.ts$/);
2933
// And load the modules.

packages/angular_devkit/build_angular/test/hello-world-lib/projects/lib/src/test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ declare const require: {
2626
// First, initialize the Angular testing environment.
2727
getTestBed().initTestEnvironment(
2828
BrowserDynamicTestingModule,
29-
platformBrowserDynamicTesting()
29+
platformBrowserDynamicTesting(),
30+
{ teardown: { destroyAfterEach: true }},
3031
);
3132
// Then we find all the tests.
3233
const context = require.context('./', true, /\.spec\.ts$/);

packages/schematics/angular/application/files/src/test.ts.template

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ declare const require: {
1717
// First, initialize the Angular testing environment.
1818
getTestBed().initTestEnvironment(
1919
BrowserDynamicTestingModule,
20-
platformBrowserDynamicTesting()
20+
platformBrowserDynamicTesting(),
21+
{ teardown: { destroyAfterEach: true }},
2122
);
23+
2224
// Then we find all the tests.
2325
const context = require.context('./', true, /\.spec\.ts$/);
2426
// And load the modules.

packages/schematics/angular/library/files/src/test.ts.template

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ declare const require: {
1818
// First, initialize the Angular testing environment.
1919
getTestBed().initTestEnvironment(
2020
BrowserDynamicTestingModule,
21-
platformBrowserDynamicTesting()
21+
platformBrowserDynamicTesting(),
22+
{ teardown: { destroyAfterEach: true }},
2223
);
24+
2325
// Then we find all the tests.
2426
const context = require.context('./', true, /\.spec\.ts$/);
2527
// And load the modules.

0 commit comments

Comments
 (0)