I have a problem with Cypress.io, here is my problem :
I have 4 different test files here :
integration/socle_full_ts_dev/1_register_user.spec.js
/// <reference types="cypress" /> import { first, last } from 'random-name'; describe('Validate register in Socle-Full-JS DEV', () => { xit('Register ramdom user on Socle', () => { cy.visit(Cypress.env('HERUKU_URL') + 'auth/register'); setTypeInRegisterForm(false) cy.wait(1000); cy.get('.register-form-button').click(); cy.wait(3000); cy.url().should('eq', Cypress.env('HERUKU_URL') + 'showcase/app/home'); }); xit('Register ramdom user on Socle with button enter', () => { cy.visit(Cypress.env('HERUKU_URL') + 'auth/register'); setTypeInRegisterForm(true); cy.wait(3000); cy.url().should('eq', Cypress.env('HERUKU_URL') + 'showcase/app/home'); }); xit('Validated register first user', () => { cy.visit(Cypress.env('MAIL_URL')); setTypeInEtherealForm(); cy.get('tbody > :nth-child(1) > :nth-child(2) > a').click(); clickLinkInEmail(); cy.wait(3000); cy.url().should('eq', Cypress.env('HERUKU_URL') + 'showcase/app/home'); }); xit('Validated register second user', () => { cy.visit(Cypress.env('MAIL_URL')); setTypeInEtherealForm(); cy.get(':nth-child(2) > :nth-child(2) > a').click(); clickLinkInEmail(); cy.wait(3000); cy.url().should('eq', Cypress.env('HERUKU_URL') + 'showcase/app/home'); }); }); const setTypeInRegisterForm = (isEnter) => { const firstName = first(); const lastName = last(); const email = firstName + '.' + lastName + '@example.fr'; cy.writeFile('cypress/fixtures/register_user.json', { firstName, lastName, email }); cy.get('#FIRST_NAME').type(firstName); cy.get('#LAST_NAME').type(lastName); cy.get('#EMAIL').type(email); cy.get('#PASSWORD').type('toto'); cy.get('#PASSWORD_CONFIRM').type('toto'); if (isEnter) { cy.get('#ORGANIZATION_NAME').type('Needone{enter}'); } else { cy.get('#ORGANIZATION_NAME').type('Needone'); } } const setTypeInEtherealForm = () => { cy.get('#address').type('toto.toto@ethereal.email'); cy.get('#password').type('LALALLA{enter}'); cy.get(':nth-child(4) > .nav-link').click(); } const clickLinkInEmail = () => { cy.get('iframe').then((iframe) => { const body = iframe.contents().find('body'); cy.wrap(body).find('a').click(); }); }
integration/socle_full_ts_local/1_register_user_local.spec.js
/// <reference types="cypress" /> import { first, last } from 'random-name'; describe('Validate register in Socle-Full-JS LOCAL', () => { it('Register ramdom user on Socle', () => { cy.visit(Cypress.env('LOCAL_URL') + 'auth/register'); setTypeInRegisterForm(false) cy.wait(1000); cy.get('.register-form-button').click(); cy.wait(3000); cy.url().should('eq', Cypress.env('LOCAL_URL') + 'showcase/app/home'); }); it('Register ramdom user on Socle with button enter', () => { cy.visit(Cypress.env('LOCAL_URL') + 'auth/register'); setTypeInRegisterForm(true); cy.wait(3000); cy.url().should('eq', Cypress.env('LOCAL_URL') + 'showcase/app/home'); }); it('Validated register first user', () => { cy.visit(Cypress.env('MAIL_URL')); setTypeInEtherealForm(); cy.get('tbody > :nth-child(1) > :nth-child(2) > a').click(); clickLinkInEmail(); cy.wait(3000); cy.url().should('eq', Cypress.env('LOCAL_URL') + 'showcase/app/home'); }); it('Validated register second user', () => { cy.visit(Cypress.env('MAIL_URL')); setTypeInEtherealForm(); cy.get(':nth-child(2) > :nth-child(2) > a').click(); clickLinkInEmail(); cy.wait(3000); cy.url().should('eq', Cypress.env('LOCAL_URL') + 'showcase/app/home'); }); }); const setTypeInRegisterForm = (isEnter) => { const firstName = first(); const lastName = last(); const email = firstName + '.' + lastName + '@example.fr'; cy.writeFile('cypress/fixtures/register_user.json', { firstName, lastName, email, password: 'password' }); cy.get('#FIRST_NAME').type(firstName); cy.get('#LAST_NAME').type(lastName); cy.get('#EMAIL').type(email); cy.get('#PASSWORD').type('password'); cy.get('#PASSWORD_CONFIRM').type('password'); if (isEnter) { cy.get('#ORGANIZATION_NAME').type('Needone{enter}'); } else { cy.get('#ORGANIZATION_NAME').type('Needone'); } } const setTypeInEtherealForm = () => { cy.get('#address').type('toto.toto@ethereal.email'); cy.get('#password').type('LALALAALAL{enter}'); cy.get(':nth-child(4) > .nav-link').click(); } const clickLinkInEmail = () => { cy.get('iframe').then((iframe) => { const body = iframe.contents().find('body'); cy.wrap(body).find('a').click(); }); }
integration/socle_full_ts_local/2_login_user_local.spec.js
/// <reference types="cypress" /> import * as userRegister from "../../fixtures/register_user.json"; describe('Test login on Socle-Full-JS LOCAL', () => { it('Login user on Socle', () => { cy.visit(Cypress.env('LOCAL_URL') + 'auth/login'); cy.get('#USERNAME').type(userRegister.email); cy.get('#PASSWORD').type(userRegister.password); cy.get('.login-form-button').click(); cy.url().should('eq', Cypress.env('LOCAL_URL') + 'showcase/app/home'); }); it('Login user on Socle with button enter', () => { cy.visit(Cypress.env('LOCAL_URL') + 'auth/login'); cy.get('#USERNAME').type(userRegister.email); cy.get('#PASSWORD').type(userRegister.password + '{enter}'); cy.url().should('eq', Cypress.env('LOCAL_URL') + 'showcase/app/home'); }); });
integration/socle_full_ts_dev/2_login_user.spec.js
/// <reference types="cypress" /> import * as userRegister from "../../fixtures/register_user.json"; describe('Test login on Socle-Full-JS DEV', () => { xit('Login user on Socle', () => { cy.visit(Cypress.env('HERUKU_URL') + 'auth/login'); cy.get('#USERNAME').type(userRegister.email); cy.get('#PASSWORD').type(userRegister.password); cy.get('.login-form-button').click(); cy.url().should('eq', Cypress.env('HERUKU_URL') + 'showcase/app/home'); }); xit('Login user on Socle with button enter', () => { cy.visit(Cypress.env('HERUKU_URL') + 'auth/login'); cy.get('#USERNAME').type(userRegister.email); cy.get('#PASSWORD').type(userRegister.password + '{enter}'); cy.url().should('eq', Cypress.env('HERUKU_URL') + 'showcase/app/home'); }); });
And the problem that I meet is that when I want to launch all the tests at the same time it turns in a loop and does not get out of it. I checked the web to see if someone had already had the problem and I didn’t find … here is a video demonstrating the problem :
Here is what i tried :
- To put tests standby with
xit
- Look in the documentation if there was anything to do with memory allocation…
- Separate tests with folders
My tests are not that complicated I just test the registration of a user and the login of the same user…
If someone has an idea ? Thanks 🙂
Advertisement
Answer
OK i have a solutions of this problem :
In my tests I have :
it('Register ramdom user on Socle', () => {
// test
});
and to solve the problem just convert its into :
it('Validated register first user', function () {
// test
});
I don’t know why, but it work !
If anyone knows why i am taker 🙂