lundi 24 février 2020

Cypress use local api server

maybe somebody use cypress for testing e2e flows together with backend API calls without some mocks.

I have a trouble right now, I want to use my local API from simple Laravel server like http://127.0.0.1:8000, but all my XHR request aborted when I run tests. After some investigations I understood that if I change request baseUrl to https://example.com then requests works fine.

Example of XHR aborting

I already set chromeWebSecurity to false.

Cypress version: 4.0.2

cypress.json

{
  "viewportWidth": 1920,
  "viewportHeight": 1000,
  "baseUrl": "http://localhost:4200",
  "watchForFileChanges": false,
  "integrationFolder": "cypress/build/cypress/integration",
  "chromeWebSecurity": false,
  "blacklistHosts": [],
  "env": {
    "host": "http://localhost:4200",
    "baseUrl": "http://127.0.0.1:8000/api"
  }
}

Aucun commentaire:

Enregistrer un commentaire