mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
perf(platform-browser): avoid including Testability by default in bootstrapApplication (#45885)
The Testability-related logic was refactored in https://github.com/angular/angular/pull/45657 to become tree-shaking-friendly: it was decoupled from the core providers of the `BrowserModule`. This commit updates the newly-introduced `bootstrapApplication` function to exclude Testability-providers by default (note: the Testability is still included in the NgModule-based bootstrap). In order to add the Testability to the app bootstrapped via `bootstrapApplication`, the `provideProtractorTestingSupport` function is introduced. PR Close #45885
This commit is contained in:
@@ -66,8 +66,22 @@ export const TESTABILITY_GETTER = new InjectionToken<GetTestability>('');
|
||||
|
||||
/**
|
||||
* The Testability service provides testing hooks that can be accessed from
|
||||
* the browser. Each bootstrapped Angular application on the page will have
|
||||
* an instance of Testability.
|
||||
* the browser.
|
||||
*
|
||||
* Angular applications bootstrapped using an NgModule (via `@NgModule.bootstrap` field) will also
|
||||
* instantiate Testability by default (in both development and production modes).
|
||||
*
|
||||
* For applications bootstrapped using the `bootstrapApplication` function, Testability is not
|
||||
* included by default. You can include it into your applications by getting the list of necessary
|
||||
* providers using the `provideProtractorTestingSupport()` function and adding them into the
|
||||
* `options.providers` array. Example:
|
||||
*
|
||||
* ```typescript
|
||||
* import {provideProtractorTestingSupport} from '@angular/platform-browser';
|
||||
*
|
||||
* await bootstrapApplication(RootComponent, providers: [provideProtractorTestingSupport()]);
|
||||
* ```
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
@Injectable()
|
||||
|
||||
Reference in New Issue
Block a user