множественное описание в спецификации приводит к странному поведению - PullRequest
0 голосов
/ 15 мая 2019

У меня есть 2 блока описания в файле спецификации.Во-первых, опишите посещения xyz.com , а во-вторых, опишите посещения abc.com

И мне нужны эти 2описать только в одной спецификации.Проводное поведение, которое я вижу, заключается в том, что тесты проходят без сбоев, но после посещения abc.com из 2-го описания он снова начинает работать 1-й описатель.Бесконечный цикл испытаний

var signedOutArtifactID = null;

describe('WEB APP E2E tests', function() {
  var token = null;

  before(function() {
    cy.visit('/');

    // Login
    cy.get('#username')
      .type(auth.geneticist.username);

    cy.get('#password')
      .type(auth.geneticist.password);

    cy.get('button')
      .contains('Login')
      .click()
      .should(function() {
        token = localStorage.getItem('token');
        expect(token).not.to.be.null;
      });
  });

  beforeEach(function() {
    localStorage.setItem('token', token);

    cy.contains('Logout')
      .should('exist');

    expect(localStorage.getItem('token'));
  });

  it('should land on home page', function() {
    cy.url()
      .should('include', '/home');
  });


  it('should save and generate and end up on signout page', function() {
    cy.contains('Save and Generate Report')
      .click();

    cy.url()
      .should('include', '/sign-out');
  });

  it('should signout and send successfully', function() {
    cy.url()
      .should(function(currentURL) {
        signedOutArtifactID = currentURL.match(/2-([0-9]+)/)[0];
        expect(signedOutArtifactID).not.to.be.null;
    });

    // Make sure interpretation was updated
    cy.get('.card-body pre')
      .should('contain', 'test interpretation added by cypress');

    cy.contains('Sign Out and Send')
      .click();

    cy.contains('Yes, sign out and send')
      .click();

  });


});


describe('2nd WEB APP E2E tests', function() {

  before(function () {
    cy.visit({
      url:`https://webappurl.com/search?scope=All&query=${signedOutArtifactID}`,
      failOnStatusCode: false
    })
  })  

  it('Review Completed step in clarity', async () => {

    cy.get('#username').type(auth.clarity_creds.username)
    cy.get('#password').type(auth.clarity_creds.password)
    cy.get('#sign-in').click()

    cy.get('.result-name').click()
    cy.get('.view-work-link').contains('QWERTYU-IDS').click()

    cy.get('.download-file-link ')
      .should(($downloads) => {
        expect($downloads).to.have.length(2)
      })

  });

});

1 Ответ

0 голосов
/ 17 мая 2019

describe определяет набор тестов. Вы можете иметь только один набор тестов верхнего уровня на файл и только один домен на тест.

Я бы просто изменил ваши describe s на context s и обернул бы оба context s в один describe, вот так:

var signedOutArtifactID = null;

describe('e2e tests', function() {

  context('WEB APP E2E tests', function() {
    var token = null;

    before(function() {
      cy.visit('/');

      // Login
      cy.get('#username')
        .type(auth.geneticist.username);

      cy.get('#password')
        .type(auth.geneticist.password);

      cy.get('button')
        .contains('Login')
        .click()
        .should(function() {
          token = localStorage.getItem('token');
          expect(token).not.to.be.null;
        });
    });

    beforeEach(function() {
      localStorage.setItem('token', token);

      cy.contains('Logout')
        .should('exist');

      expect(localStorage.getItem('token'));
    });

    it('should land on home page', function() {
      cy.url()
        .should('include', '/home');
    });


    it('should save and generate and end up on signout page', function() {
      cy.contains('Save and Generate Report')
        .click();

      cy.url()
        .should('include', '/sign-out');
    });

    it('should signout and send successfully', function() {
      cy.url()
        .should(function(currentURL) {
          signedOutArtifactID = currentURL.match(/2-([0-9]+)/)[0];
          expect(signedOutArtifactID).not.to.be.null;
      });

      // Make sure interpretation was updated
      cy.get('.card-body pre')
        .should('contain', 'test interpretation added by cypress');

      cy.contains('Sign Out and Send')
        .click();

      cy.contains('Yes, sign out and send')
        .click();

    });


  });


  context('2nd WEB APP E2E tests', function() {

    before(function () {
      cy.visit({
        url:`https://webappurl.com/search?scope=All&query=${signedOutArtifactID}`,
        failOnStatusCode: false
      })
    })  

    it('Review Completed step in clarity', async () => {

      cy.get('#username').type(auth.clarity_creds.username)
      cy.get('#password').type(auth.clarity_creds.password)
      cy.get('#sign-in').click()

      cy.get('.result-name').click()
      cy.get('.view-work-link').contains('QWERTYU-IDS').click()

      cy.get('.download-file-link ')
        .should(($downloads) => {
          expect($downloads).to.have.length(2)
        })

    });

  });

})
...