Skip to content

Commit 07418ae

Browse files
mgoldberg524mmalerba
authored andcommitted
test(cdk/testing): add includeAsyncTests flag (#25542)
* test(cdk/testing): add includeAsyncTests flag This is needed by some downstream custom angular harnesses that use this set of tests but also do not rely on Angular framework stabilization. * test(cdk/testing): rework `includeAsyncTests` into `skipAsyncTests` * test(cdk/testing): fix stale param doc (cherry picked from commit 7faafb4)
1 parent 8683f47 commit 07418ae

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/cdk/testing/tests/cross-environment.spec.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {SubComponentHarness, SubComponentSpecialHarness} from './harnesses/sub-c
2828
* @param getHarnessLoaderFromEnvironment env specific closure to get HarnessLoader
2929
* @param getMainComponentHarnessFromEnvironment env specific closure to get MainComponentHarness
3030
* @param getActiveElementId env specific closure to get active element
31+
* @param skipAsyncTests skip tests that rely on Angular framework stabilization
3132
*
3233
* @docs-private
3334
*/
@@ -37,6 +38,7 @@ export function crossEnvironmentSpecs(
3738
// Maybe we should introduce HarnessLoader.getActiveElement(): TestElement
3839
// then this 3rd parameter could get removed.
3940
getActiveElementId: () => Promise<string | null>,
41+
skipAsyncTests: boolean = false,
4042
) {
4143
describe('HarnessLoader', () => {
4244
let loader: HarnessLoader;
@@ -201,13 +203,6 @@ export function crossEnvironmentSpecs(
201203
expect(items4.length).toBe(0);
202204
});
203205

204-
it('should wait for async operation to complete', async () => {
205-
const asyncCounter = await harness.asyncCounter();
206-
expect(await asyncCounter.text()).toBe('5');
207-
await harness.increaseCounter(3);
208-
expect(await asyncCounter.text()).toBe('8');
209-
});
210-
211206
it('should send enter key', async () => {
212207
const specialKey = await harness.specaialKey();
213208
await harness.sendEnter();
@@ -287,6 +282,15 @@ export function crossEnvironmentSpecs(
287282
expect(element).toBeTruthy();
288283
expect(await element.getText()).toBe('Has comma inside attribute');
289284
});
285+
286+
if (!skipAsyncTests) {
287+
it('should wait for async operation to complete', async () => {
288+
const asyncCounter = await harness.asyncCounter();
289+
expect(await asyncCounter.text()).toBe('5');
290+
await harness.increaseCounter(3);
291+
expect(await asyncCounter.text()).toBe('8');
292+
});
293+
}
290294
});
291295

292296
describe('HarnessPredicate', () => {

0 commit comments

Comments
 (0)