Skip to content

Commit 342c15e

Browse files
authored
feat(cdk-experimental/testing): Add a public stabilize method to TestElement (#16847)
* feat(cdk-experimental/testing): Add a public stabilize method to TestElement * rename to `forceStabilize`
1 parent 5194bea commit 342c15e

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/cdk-experimental/testing/protractor/protractor-element.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,6 @@ export class ProtractorElement implements TestElement {
141141
async getProperty(name: string): Promise<any> {
142142
return browser.executeScript(`return arguments[0][arguments[1]]`, this.element, name);
143143
}
144+
145+
async forceStabilize(): Promise<void> {}
144146
}

src/cdk-experimental/testing/test-element.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,7 @@ export interface TestElement {
9090
/** Gets the text from the element. */
9191
text(): Promise<string>;
9292

93-
/**
94-
* Gets the value for the given attribute from the element. If the attribute does not exist,
95-
* falls back to reading the property.
96-
*/
93+
/** Gets the value for the given attribute from the element. */
9794
getAttribute(name: string): Promise<string | null>;
9895

9996
/** Checks whether the element has the given class. */
@@ -104,4 +101,11 @@ export interface TestElement {
104101

105102
/** Gets the value of a property of an element. */
106103
getProperty(name: string): Promise<any>;
104+
105+
/**
106+
* Flushes change detection and async tasks.
107+
* In most cases it should not be necessary to call this. However, there may be some edge cases
108+
* where it is needed to fully flush animation events.
109+
*/
110+
forceStabilize(): Promise<void>;
107111
}

src/cdk-experimental/testing/testbed/unit-test-element.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,8 @@ export class UnitTestElement implements TestElement {
137137
await this._stabilize();
138138
return (this.element as any)[name];
139139
}
140+
141+
async forceStabilize(): Promise<void> {
142+
return this._stabilize();
143+
}
140144
}

0 commit comments

Comments
 (0)