Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1cd65a0

Browse filesBrowse files
committed
fix(@angular/build): perform testing module cleanup when using Vitest
Ensure proper cleanup of the Angular testing module when running tests with Vitest. Closes: #30186 (cherry picked from commit 8e0b14f)
1 parent fa0a06f commit 1cd65a0
Copy full SHA for 1cd65a0

File tree

Expand file treeCollapse file tree

1 file changed

+7
-1
lines changed
Filter options
  • packages/angular/build/src/builders/unit-test
Expand file treeCollapse file tree

1 file changed

+7
-1
lines changed

‎packages/angular/build/src/builders/unit-test/builder.ts

Copy file name to clipboardExpand all lines: packages/angular/build/src/builders/unit-test/builder.ts
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,14 @@ export async function* execute(
124124
loadContent: async () => {
125125
const contents: string[] = [
126126
// Initialize the Angular testing environment
127-
`import { getTestBed } from '@angular/core/testing';`,
127+
`import { getTestBed, ɵgetCleanupHook as getCleanupHook } from '@angular/core/testing';`,
128128
`import { BrowserTestingModule, platformBrowserTesting } from '@angular/platform-browser/testing';`,
129+
`import { beforeEach, afterEach } from 'vitest';`,
130+
'',
131+
// Same as https://github.com/angular/angular/blob/05a03d3f975771bb59c7eefd37c01fa127ee2229/packages/core/testing/src/test_hooks.ts#L21-L29
132+
`beforeEach(getCleanupHook(false));`,
133+
`afterEach(getCleanupHook(true));`,
134+
'',
129135
`getTestBed().initTestEnvironment(BrowserTestingModule, platformBrowserTesting(), {`,
130136
` errorOnUnknownElements: true,`,
131137
` errorOnUnknownProperties: true,`,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.