Cypress not able to call http xhr on different localhost port

Discussão em 'Angular' iniciado por HamidIng, Dezembro 16, 2024.

  1. HamidIng

    HamidIng Guest

    I'm running and angular app (angular 18) in dev mode (npm run start), the app runs on http://localhost:4200/. I have a simple Cypress test to visit the home page and check the title of the app. When running the test: (cypress open --browser chrome), my app is not able to call public API of the backend that is running on http://localhost:16105/. If I use curl to call the endpoint directly, the endpoint works correctly. The angular app is calling multiple public API when loading and the problem occur on each.

    cypress.config.ts

    import { defineConfig } from 'cypress';

    export default defineConfig({
    projectId: "XXXXX",
    defaultCommandTimeout: 10000,
    requestTimeout: 10000,
    chromeWebSecurity: false,

    retries: {
    runMode: 3,
    openMode: 0,
    },

    e2e: {
    baseUrl: 'http://localhost:4200',
    experimentalStudio: true,
    excludeSpecPattern: "*.js",
    specPattern: ["cypress/e2e/**/+(all.ts|*.cy.ts)", "cypress/e2e/**/**/*.cy.ts)"],
    },
    });



    Nodejs version : 20.18.0

    Angular 18

    [​IMG]

    Continue reading...

Compartilhe esta Página