小编Wou*_*ouX的帖子

Cypress - 如何按顺序运行测试文件

当我按下“运行所有规格”按钮或使用运行赛普拉斯中所有文件的运行命令时,它会按字母顺序运行所有测试文件,所以我不想要那样。

我想用我自己的规则对它们进行排序。


假设我在聊天应用程序测试中有 3 个步骤。

  1. 可以连接聊天应用
  2. 可以连接聊天
  3. 用户是否可以发送消息

我想测试每一步,而不是相互绑定。我的意思是,测试自己的功能之一。我做的是如下

chat_app_connect.spec.js

describe('Server Connecting Test', () => {
    it('Visit Server page', () => {
        cy.visit('https://chat.page..');
    });

    it('Check welcome messages', () => {
        cy.contains('Live Support');
        cy.contains('Hello, Stranger');
    });

    it('Check URL and status of circle', () => {
        // URL
        cy.url()
            .should('include', '/hello');
        // Status Circle    
        cy.get('circle')
            .should('have.class', 'positive');
    });
});
Run Code Online (Sandbox Code Playgroud)

chat_connect.spec.js

import './chat_app_connect.spec.js';

describe('Chat Connecting Test', () => {
    it('Type customer name', () => {
        cy.get('input')
            .clear()
            .type('E2E Test');
    });
    it('Click …
Run Code Online (Sandbox Code Playgroud)

automated-tests cypress

20
推荐指数
4
解决办法
1万
查看次数

标签 统计

automated-tests ×1

cypress ×1