Skip to content

test(cdk/testing): add includeAsyncTests flag #25542

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/cdk/testing/tests/cross-environment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {SubComponentHarness, SubComponentSpecialHarness} from './harnesses/sub-c
* @param getHarnessLoaderFromEnvironment env specific closure to get HarnessLoader
* @param getMainComponentHarnessFromEnvironment env specific closure to get MainComponentHarness
* @param getActiveElementId env specific closure to get active element
* @param skipAsyncTests skip tests that rely on Angular framework stabilization
*
* @docs-private
*/
Expand All @@ -37,6 +38,7 @@ export function crossEnvironmentSpecs(
// Maybe we should introduce HarnessLoader.getActiveElement(): TestElement
// then this 3rd parameter could get removed.
getActiveElementId: () => Promise<string | null>,
skipAsyncTests: boolean = false,
) {
describe('HarnessLoader', () => {
let loader: HarnessLoader;
Expand Down Expand Up @@ -201,13 +203,6 @@ export function crossEnvironmentSpecs(
expect(items4.length).toBe(0);
});

it('should wait for async operation to complete', async () => {
const asyncCounter = await harness.asyncCounter();
expect(await asyncCounter.text()).toBe('5');
await harness.increaseCounter(3);
expect(await asyncCounter.text()).toBe('8');
});

it('should send enter key', async () => {
const specialKey = await harness.specaialKey();
await harness.sendEnter();
Expand Down Expand Up @@ -287,6 +282,15 @@ export function crossEnvironmentSpecs(
expect(element).toBeTruthy();
expect(await element.getText()).toBe('Has comma inside attribute');
});

if (!skipAsyncTests) {
it('should wait for async operation to complete', async () => {
const asyncCounter = await harness.asyncCounter();
expect(await asyncCounter.text()).toBe('5');
await harness.increaseCounter(3);
expect(await asyncCounter.text()).toBe('8');
});
}
});

describe('HarnessPredicate', () => {
Expand Down