Skip to content
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

Firefox Cross Origin Error Causing False-Positives / Unusual Errors #26484

Open
emilyrohrbough opened this issue Apr 11, 2023 · 0 comments
Open
Labels
browser: firefox E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: bug type: unexpected behavior User expected result, but got another

Comments

@emilyrohrbough
Copy link
Member

Current behavior

In Cypress <12, test would fail with the following error:

You attempted to make a chai-jQuery assertion on an object that is neither a DOM object or a jQuery object.

In Cypress 12+

TypeError: $el.css is not a function error.

This error occurs ONLY in Firefox.

Findings

Issue: Chrome is working as expect by showing the correct error, where Firefox is showing this weird TypeError instead of the expected Cypress command error.

Findings: I have gone down quite the rabbit hole with this issue & I have narrowed down what is likely causing this issue to present itself.

  • slimming down to one test - I am see the correct pass/fail of the element existence when slimming cy.get('.template-grid-item-title').should('be.visible') to cy.get('.template-grid-item-title') (I reduced this because get will verify existence for the use).
  • after re-adding the first test.
    • I am seeing a firefox cross-origin script error surfacing in the second test from the first test’s fetch requests bleeding over (known issue but can’t find it 😕 )
    • this is causing two problems
      • causing the beforeEach hook to never execute the session command to restore the session
      • causing the cy.get('.template-grid-item-title') command to incorrectly “pass” when it doesn't exist
      • OR causing cy.get('.template-grid-item-title').should('be.visible') to report the weird TypeError: $el.css is not a function error because the subject never successfully queried and is undefined.
  • After adding cy.wait(7000) (arbitrary timeout) to the first test, I am no longer seeing the cross origin script error and see no issues with querying the page in the second test
  • When I remove the beforeEach hook and move calling cy.session() into the test body of each test, I am getting a false-positive passing test when no cypress commands actually executing at all 😰

Seem like this is an issue combination with test isolation + hanging xhr requests bleeding into the next test + Cypress doing something funky when it sees that error and providing false-positives when running in Firefox.

Desired behavior

Cypress correctly fails when cross-script error occurs in Cypress instead of false-reporting and/or skipping hooks in the queue.

Test code to reproduce

context('example', function () {
  beforeEach(function () {
    // details stored internally. - @emilyrohrbough
    login(xxxx, xxxx);
  });

 it('Test 1', function () {
    cy.visit('https://secure.vidyard.com');
  });

  it('Test 2', function () {
    cy.visit('https://secure.vidyard.com');
    cy.get('.template-grid-item-title')
    .should('be.visible');
    // .should('exist');
  });
});

const login = (email, password) => {
  cy.session([email, password], () => {
    cy.visit('https://auth.vidyard.com');
    cy.get('#username').type(email);
    cy.get('#next-login').click();
    cy.get('[data-testid="password-input"]').type(password);
    cy.get('#sign-in').click();
    cy.url().should('include', '/library');
  }, {
    validate() {
      cy.document().its('cookie').should('contain', '_ga')
    }
  });
};

Cypress Version

12.9.0

Node version

16.16.0

Operating System

MacOS 12.5.1

Debug Logs

No response

Other

No response

@nagash77 nagash77 added E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. and removed routed-to-e2e labels Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
browser: firefox E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: bug type: unexpected behavior User expected result, but got another
Projects
None yet
Development

No branches or pull requests

2 participants