Unable to run @applitools/cypress-eyes against localhost

190 Views Asked by At

I am trying to use Applitools eyes with cypress within the Nx ecosystem, however this fails with the following error:

CypressError: `cy.visit()` failed trying to load:
http://localhost:4200/
We attempted to make an http request to this URL but the request failed without a response.
We received this error at the network level:
  > Error: connect ECONNREFUSED 127.0.0.1:4200
Common situations why this would fail:
  - you don't have internet access
  - you forgot to run / boot your web server
  - your web server isn't accessible
  - you have weird network configuration settings on your computer

I have the following versions installed: "@applitools/eyes-cypress": "3.32.2" "cypress": "12.12.0"

Below is my test file:

describe('Applitools-eyes - ultrafast grid - @visual-regression', () => {
  beforeEach(() => {
    cy.eyesOpen({
      appName: 'next-app',
      batchName: 'Example: Cypress Typescript with the Ultrafast Grid',
      browser: [
        { width: 1920, height: 1080, name: 'chrome' }, // Specify the Chrome browser with a resolution of 1920x1080
      ],
      testName: Cypress.currentTest.title,
    });
  });

  it('should check the main page', () => {
    cy.visit('/');

    cy.eyesCheckWindow({
      tag: 'Home Page',
      target: 'window',
      fully: true,
      matchLevel: 'Strict',
    });
  });

  afterEach(() => {
    cy.eyesClose();
  });

  after(() => {
    cy.eyesGetAllTestResults().then((summary) => {
      console.log(summary);
    });
  });
});

As the baseUrl has been set within my cypress.config.ts file, cy.visit('/') should navigate to the homepage of my application. When running other tests this works absolutely fine, however any tests which start with cy.eyesOpen() result in test failing.

As this is an Nx application, I am using the @nrwl/cypress plugin to test the application. This serves the application to localhost first (which I can navigate to and see if fully loaded), then the cypress tests are started, so the application is definitely up and running.

I have tried downgrading versions of applitools/eyes-cypress but still face the issue, additionally I have attempted to set things such as 'retryOnNetworkFailure' and 'timeout' within the cy.visit() function without luck.

Worth noting that for any cypress spec files in the repository, if this eyes test loads first, everything else fails on the same issue. Remove the eyes test and everything works again.

0

There are 0 best solutions below