我在Cypress.io上有问题,这是我的问题:
我在这里有4个不同的测试文件:
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('[email protected]');
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('[email protected]');
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');
});
});
而且,我遇到的问题是,当我想同时启动所有测试时,它变成一个循环并且不会退出。我在网上检查了一下是否有人已经遇到了问题,但是我没有找到...这是一个演示问题的视频:
这是我尝试过的:
xit
一起待机我的测试并不复杂,我只是测试一个用户的注册和同一用户的登录...
如果有人有想法?谢谢:)
在我的测试中,我有:
it('Register ramdom user on Socle', () => {
// test
});
并且要解决问题,只需将其转换为:
it('Validated register first user', function () {
// test
});
我不知道为什么,但是有效!
如果有人知道我为什么要接受:)