question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UI: "Found undefined alias for 'myalias'" when multiple aliases defined for element

See original GitHub issue

Current behavior:

When using .as('myalias') in a loop the message Found undefined alias for: 'myalias' shows up in the UI but it still works (in the console you can see that the alias resolved to two elements).

The message does not show up when the loop is only executed once.

Desired behavior:

This message should not appear and irritate the developer 😃

Steps to reproduce: (app code and test code)

describe('Test', () => {
  it('test', () => {
    cy.visit('http://google.com');
    for (let i = 0; i < 2; i += 1) {
      cy.get('[name="btnK"]').as('search-button');
      cy.get('@search-button');
    }
  });
});

Versions

Cypress 3.3.1
OS Windows 10
Browsers Electron headed

PS:

Am I using aliases incorrectly here or is this just a misguided message from the UI?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jennifer-shehanecommented, Jun 17, 2019

Oh, yeah, this is a bug. This isn’t even concerned with the loop, it seems that when using aliases for elements, if more than 1 is matching, the UI messes up a bit and displays this undefined message.

I believe this was introduced in this PR https://github.com/cypress-io/cypress/pull/2960

Code to reproduce:

it('test', () => {
  cy.visit('http://google.com')
  cy.get('[name="btnK"]').as('search-button')
  cy.get('@search-button')
  cy.get('[name="btnK"]').as('search-button')
  cy.get('@search-button')
})
0reactions
jennifer-shehanecommented, Oct 19, 2020

This issue will be closed to further comment as the exact issue here was resolved and tested.

If you’re experiencing a bug similar to this in Cypress, please open a new issue with a fully reproducible example that we can run. There may be a specific edge case with the issue that we need more detail to fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack doesn't resolve properly my alias - Stack Overflow
Finnaly I found the problem was that I wrote resolve twice. And the second resolve override the previous one. My code is like...
Read more >
Defining Aliases for a User Catalog - IBM
You can define aliases for the catalog in the same job in which you define the catalog by including DEFINE ALIAS commands after...
Read more >
Aliases | Apache Solr Reference Guide 8.5
Any alias (standard or routed) that references multiple collections may complicate relevancy. By default, SolrCloud scores documents on a per-shard basis.
Read more >
Why doesn't my Bash script recognize aliases?
If you look into the bash manpage you find: Aliases are not expanded when the shell is not interactive, unless the expand_aliases shell...
Read more >
SELECT | InterSystems IRIS Data Platform 2022.2
FROM table AS tableAlias, table2 AS tableAlias2, ... sets an alias for multiple tables. You can use table aliases to indicate which table...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found