代码之家  ›  专栏  ›  技术社区  ›  raju

一次编写多个测试(it)。规格:柏树

  •  0
  • raju  · 技术社区  · 3 年前

    我正在尝试编写多个测试( it 块)在单个 spec.ts 文件(角度+NX项目)。我的问题是,在执行第一个测试之前,第二个测试已经开始执行,这会阻止第一个测试运行。

    在下面的例子中,第二个 信息技术 阻止执行第一个:

    import { login } from '../support/util';
    
    /// <reference types="cypress-xpath" />
    
    describe('merkur helper json-management functionality', () => {
      before(() => cy.visit(Cypress.env('baseUrl')));
    
      it('logs in and goto json-management module', async () => {
        const uuid = () => Cypress._.random(0, 1e6)
        const id = uuid()
        const testFormName = `testname${id}`
    
        login('sadmin', '87654321');
        cy.wait(3000);
        cy.visit(`${Cypress.env('CYPRESS_BASE_URL')}/#/json-management`);
        cy.wait(1000);
        cy.location('href').should('include', '/json-management');
        cy.wait(1000);    
    
      });
    
      it('should go into a distributor modules section', async () => {
        cy.log('++++++++++++++++++++++++++++++++++++++')  
    
      });
    
    
    });
    
    0 回复  |  直到 3 年前
        1
  •  0
  •   Putra Prima A    3 年前

    不应在it块上使用async()。 这是一个典型的测试,用它在cypress中阻塞

    describe('My First Test', () => {
      it('Does not do much!', () => {
        expect(true).to.equal(true)
      })
    })
    
    

    您可以阅读有关文档的更多详细信息

    https://docs.cypress.io/guides/getting-started/writing-your-first-test#Write-your-first-test