Skip to content

docs(testing): improve standalone testing documentation - #31313

Open
Zac-Smucker-Bryan wants to merge 1 commit into
ionic-team:mainfrom
Zac-Smucker-Bryan:standalone-testing-docs-update
Open

docs(testing): improve standalone testing documentation#31313
Zac-Smucker-Bryan wants to merge 1 commit into
ionic-team:mainfrom
Zac-Smucker-Bryan:standalone-testing-docs-update

Conversation

@Zac-Smucker-Bryan

Copy link
Copy Markdown
Contributor

Issue number: resolves #31312


What is the current behavior?

Current docs don't provide recommended testing guidance for accurately testing standalone components. This can create issues because a standalone (custom-elements) build doesn't expose el.componentOnReady(), so any test that reads fixture.nativeElement before hydration in a standalone project has the potential to not be testing what they think they are.

What is the new behavior?

  • Adds a couple of sentences to talk about using the existing componentOnReady helper from @ionic/core in Angular's testing.md file
  • Adds the same standalone guidance to the testing.md files for React and Vue

Does this introduce a breaking change?

  • Yes
  • No

Add context about using exported `componentOnReady` helper to make tests more accurate for custom-element builds.
@Zac-Smucker-Bryan
Zac-Smucker-Bryan requested a review from a team as a code owner July 31, 2026 02:26
@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

@Zac-Smucker-Bryan is attempting to deploy a commit to the Ionic Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ionic-framework Ready Ready Preview Aug 3, 2026 10:58pm

Request Review

@Zac-Smucker-Bryan Zac-Smucker-Bryan changed the title docs: improve standalone testing documentation docs(testing): improve standalone testing documentation Aug 4, 2026

@thetaPC thetaPC left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up, the Angular section is solid. The React and Vue sections are that same section copied across though, and the facts don't carry over (no /standalone route in either test app, no IonicModule outside Angular), so please verify guidance against each framework's own source before duplicating it. Suggestions left inline.

Comment thread docs/react/testing.md

If you need to add E2E tests that are only run on a specific version of the JS Framework, replicate the `VersionTest` component on each partial application. This ensures that tests for framework version X do not get run for framework version Y.

### Testing Standalone Ionic Components

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Testing Standalone Ionic Components
### Testing Ionic Components

Comment thread docs/react/testing.md
Comment on lines +48 to +50
Tests for standalone Ionic UI components should only be added under the `/standalone` route. This allows for an isolated environment where the lazy loaded `IonicModule` is not initialized. The standalone components use Stencil's custom element bundle instead of the lazy loaded bundle. If `IonicModule` is initialized then the Stencil components will fall back to using the lazy loaded implementation instead of the custom elements bundle implementation.

When testing Ionic components, use the exported `componentOnReady` helper from `@ionic/core` instead of calling `el.componentOnReady()` directly. The helper works with both lazy-loaded and custom-element builds, making it more likely the component has finished rendering before making assertions against its rendered DOM or running accessibility tests.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rewritten to describe how components actually load in the React test apps, with the componentOnReady guidance kept as a note for if we add unit tests later.

Suggested change
Tests for standalone Ionic UI components should only be added under the `/standalone` route. This allows for an isolated environment where the lazy loaded `IonicModule` is not initialized. The standalone components use Stencil's custom element bundle instead of the lazy loaded bundle. If `IonicModule` is initialized then the Stencil components will fall back to using the lazy loaded implementation instead of the custom elements bundle implementation.
When testing Ionic components, use the exported `componentOnReady` helper from `@ionic/core` instead of calling `el.componentOnReady()` directly. The helper works with both lazy-loaded and custom-element builds, making it more likely the component has finished rendering before making assertions against its rendered DOM or running accessibility tests.
`@ionic/react` imports every component through `defineCustomElement` from `@ionic/core/components`, so every test runs against the custom elements build.
These test apps are Cypress only, and Cypress retries assertions until they pass, so there is nothing to wait on manually today. If we add unit tests that assert against rendered DOM, use the `componentOnReady` helper exported from `@ionic/core` rather than calling `el.componentOnReady()` directly. That method does not exist on custom elements, so the direct call throws. The helper waits one animation frame instead, giving the component's inner contents a chance to render.

Comment thread docs/vue/testing.md

If you need to add E2E tests that are only run on a specific version of the JS Framework, replicate the `VersionTest` component on each partial application. This ensures that tests for framework version X do not get run for framework version Y.

### Testing Standalone Ionic Components

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Testing Standalone Ionic Components
### Testing Ionic Components

Comment thread docs/vue/testing.md

### Testing Standalone Ionic Components

Tests for standalone Ionic UI components should only be added under the `/standalone` route. This allows for an isolated environment where the lazy loaded `IonicModule` is not initialized. The standalone components use Stencil's custom element bundle instead of the lazy loaded bundle. If `IonicModule` is initialized then the Stencil components will fall back to using the lazy loaded implementation instead of the custom elements bundle implementation.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Tests for standalone Ionic UI components should only be added under the `/standalone` route. This allows for an isolated environment where the lazy loaded `IonicModule` is not initialized. The standalone components use Stencil's custom element bundle instead of the lazy loaded bundle. If `IonicModule` is initialized then the Stencil components will fall back to using the lazy loaded implementation instead of the custom elements bundle implementation.
`@ionic/vue` imports every component through `defineCustomElement` from `@ionic/core/components`, so every test runs against the custom elements build.
These test apps are Cypress only, and Cypress retries assertions until they pass, so there is nothing to wait on manually today. If we add unit tests that assert against rendered DOM, use the `componentOnReady` helper exported from `@ionic/core` rather than calling `el.componentOnReady()` directly. That method does not exist on custom elements, so the direct call throws. The helper waits one animation frame instead, giving the component's inner contents a chance to render.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: documentation for standalone component testing

2 participants