diff --git a/CYPRESS.md b/CYPRESS.md index aa20594a..e18c4050 100644 --- a/CYPRESS.md +++ b/CYPRESS.md @@ -59,6 +59,31 @@ describe('while demo spec', () => { ## Targetting elements Cypress uses DOM selectors to target elements. Use the `data-cy` attribute to target elements. +## ShadowDOM + +Fore uses the shadowdom extensively. Cypress can target into shadow roots, but not with normal DOM +selectors. Take the [`i18n`](./cypress/e2e/i18n/i18n.cy.ts) tests for example. Here the `fx-output` +contains a text that we want to assert. We use the `shadow()` method to peer into there. + +```typescript + it('can toggle the language', function() { + cy.get('[data-cy="EN"]').click(); + cy + .get('fx-output') + .shadow() + .find('#value') + .should('contain', 'Description of object'); + cy + .get('[data-cy="DE"]') + .click(); + cy + .get('fx-output') + .shadow() + .find('#value') + .should('contain', 'Objektbeschreibung'); + }); +``` + ## Cypress versus unit tests Because Cypress takes away all timing issues, they are easier to write than normal unit diff --git a/demo/i18n/i18n.html b/demo/i18n/i18n.html index f45b0707..2333e72b 100644 --- a/demo/i18n/i18n.html +++ b/demo/i18n/i18n.html @@ -40,11 +40,11 @@