更新 Playwright 配置以增加超时设置,重构测试用例以提高可读性和结构清晰度

This commit is contained in:
LingandRX 2024-11-09 22:16:04 +08:00
parent 44a701cbed
commit be91605c3c
3 changed files with 14 additions and 6 deletions

View File

@ -30,6 +30,12 @@ module.exports = defineConfig({
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
timeout: 5 * 60000,
expect: {
toPass: {
timeout: 30000,
},
},
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: process.env.BASE_URL,

View File

@ -8,11 +8,11 @@ test.describe
const customer = new Customer(1, 1, { phone: phone });
console.log(`${customer.phone}-${customer.username}`);
test('创建顾客', async ({ touchCustomerPage }) => {
await touchCustomerPage.createCustomer(customer);
});
test('登录touch和h5创建顾客购买会员卡', async ({ touchPage, touchCustomerPage }) => {
await test.step('创建顾客', async () => {
await touchCustomerPage.createCustomer(customer);
});
test('登录touch和h5创建顾客购买会员卡', async ({ touchPage }) => {
await test.step('在touch页面购买会员卡', async () => {
await touchPage.getByText('去开单').click();
await touchPage.locator('.more > .icon > svg').click();

View File

@ -65,8 +65,10 @@ test('csv', async ({ zhbPage }, workerInfo) => {
.locator('span')
.first()
.click();
await zhbPage.getByRole('button', { name: '完成开单' }).click();
await expect(zhbPage.getByRole('button', { name: '结账' })).toBeVisible();
await expect(async () => {
await zhbPage.getByRole('button', { name: '完成开单' }).click();
await expect(zhbPage.getByRole('button', { name: '结账' })).toBeVisible({ timeout: 2000 });
}).toPass();
await zhbPage.getByRole('button', { name: '结账' }).click();
await zhbPage.locator('#page_footBathPay').getByText('结算签字').click();