abramenal/cypress-shadow-dom

[Feature] - add support for aliasing

DesignByOnyx opened this issue · 0 comments

Current behavior:

There is currently no way to share objects between tests. This results in a lot of get/find operations for every test as each test needs to repeatedly pierce into the same shadow structures before making any assertions.

Desired behavior:

Enable the as('alias') or shadowAs('alias') command to work and allow shadowGet('@alias') to retrieve these values. This should use mocha's "context". Note: there's a possibility that the default "as" command already works and we just need to update shadowGet.

beforeEach(() => {
  cy.shadowGet('todo-list')
    .shadowFind('todo-item')
    .as('todoItem');
});

it('does the thing', () => {
  cy.shadowGet('@todoItem').shadowContains('do the laundry');
});