赛普拉斯:运行 所有规范,但创建一个没有 运行 规范的循环
Cypress: Run all specs but create a loop without run specs
我对 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('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');
});
});
我遇到的问题是,当我想同时启动所有测试时,它会进入一个循环并且无法退出。
我在网上查了看是否有人遇到过这个问题,但我没有找到……
这是演示问题的视频:
这是我尝试过的:
- 使用
xit
使测试处于待机状态
- 查看文档是否与内存分配有关...
- 用文件夹分开测试
我的测试没有那么复杂我只是测试一个用户的注册和同一个用户的登录...
如果有人有想法?谢谢:)
好的,我有这个问题的解决方案:
在我的测试中我有:
it('Register ramdom user on Socle', () => {
// test
});
要解决问题,只需将其转换为:
it('Validated register first user', function () {
// test
});
我不知道为什么,但它有效!
If anyone knows why i am taker :)
我对 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('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');
});
});
我遇到的问题是,当我想同时启动所有测试时,它会进入一个循环并且无法退出。 我在网上查了看是否有人遇到过这个问题,但我没有找到…… 这是演示问题的视频:
这是我尝试过的:
- 使用
xit
使测试处于待机状态
- 查看文档是否与内存分配有关...
- 用文件夹分开测试
我的测试没有那么复杂我只是测试一个用户的注册和同一个用户的登录...
如果有人有想法?谢谢:)
好的,我有这个问题的解决方案:
在我的测试中我有:
it('Register ramdom user on Socle', () => {
// test
});
要解决问题,只需将其转换为:
it('Validated register first user', function () {
// test
});
我不知道为什么,但它有效!
If anyone knows why i am taker :)