I have a project that I am successfully launching and writing tests for it in cypress.
When I launch the app, my locahost address is 3000. This is the address of my front-end project
I add text attributes to components in order to optimize my test library. However, after I use the address of the local frontend, I cannot log in. I am getting a POST/login-via-password 404 and html error from NGINX. It turns out that cypress does not process cross-requests
It would be convenient for me to work directly at the local address and the dev backend. Because if I only work on the dev frontend and dev backend, I need to switch constantly and it will take a lot of time
cypress.config.ts
export default defineConfig(
{
reporter: 'cypress-multi-reporters',
reporterOptions: {
reporterEnabled: 'cypress-qase-reporter',
cypressMochawesomeReporterReporterOptions: {
charts: true,
},
cypressQaseReporterReporterOptions: {
debug: true,
testops: {
api: {
token: 'xxx',
},
project: 'xxx',
uploadAttachments: true,
run: {
complete: true,
},
},
framework: {
cypress: {
screenshotsFolder: 'cypress/screenshots',
}
}
},
},
video: false,
e2e:
{
...nxE2EPreset(__dirname),
experimentalSessionAndOrigin: true,
projectId: "xxx",
supportFile: false,
specPattern: ['./__tests__/**/*.spec.ts'],
screenshotsFolder: '__tests__/reports/screenshots',
videosFolder: '__tests__/reports/video',
chromeWebSecurity: false,
},
});
and my test
describe('User login with valid credentials', () => {
beforeEach(() => {
cy.session('login', () => {
cy.visit(`${devUrl}/login`);
//type data
cy.get(emailInput)
.type(Cypress.env('valid_email'));
cy.get(passwordInput)
.type(Cypress.env('valid_password'));
cy.get(submitButton)
.click();
cy.get('.gap-14 > .flex > .text-extra-large-bold')
.should('be.visible');
cy.wait(1000)
})
Аfter entering the username and password, a login should occur, but there is no redirect and I get a 404 with a modal window “failed to log in”
I repeat, if I switch to the frontend of the dev environment, then cypress will perfectly make redirects and the login will be successful
- Install the security certificate
- Launch the browser in disable sertificate mode