mercredi 10 octobre 2018

I am using angular and protractor e2e test. How to reduce the time it takes each test to start?

I have this test e2e in protractor:

describe('My App', () => {
 beforeEach(() => {
   // browser.waitForAngularEnabled(false);
 });
 let page: AppPage;
 it('Debe Crear una nueva especie', () => {
   page = new AppPage();
   page.navigateTo().then(() => {
     // if (!browser.waitForAngularEnabled()) { browser.waitForAngularEnabled(true); } 
    });
    page.getLinkEspecies().click().then(() => {
      console.log("HIZO CLICK")
      //Presiona boton 'Nueva Especie'
      page.getButtonNuevaEspecie().click();
      // browser.sleep(1000)
      //Setear categoria, especie y modelo
      page.getOptionCategoria().click();
      // browser.sleep(1000)
      page.getOptionTipoEspecie().click();
      // browser.sleep(1000)
      page.getOptionEspecieComoModelo().click();
      // browser.sleep(1000)
      //Presiona boton 'Continuar'
      page.getButtonContinuar().click();
      // browser.sleep(1000)
      //Presiona boton 'Guardar especie'
      page.getButtonGuardarEspecie().click().then(
        () => {
          browser.wait(page.getAlertMessage().isPresent(), 20000, "FALLO").then(
            () => {
              // browser.sleep(2000)
              page.getAlertMessage().getText().then(
                (texto: string) => {
                  expect(texto).toEqual('Se creo correctamente')
                }
              )
            }
          );
          expect(browser.getCurrentUrl()).toMatch('/#/especies');
        }
      );
    });
  });

});

My conf of protractor is:

exports.config = {
  allScriptsTimeout: 300000,
  seleniumServerStartTimeout: 0,
  specs: [
    './e2e/**/*.e2e-spec.ts'
  ],
  capabilities: {
    'browserName': "chrome",
    // this takes seconds so 120 would be 120 seconds.
    // 'idleTimeout': '10'
  },
  directConnect: true,
  baseUrl: 'http://localhost:4200/',
  framework: 'jasmine',
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 300000,
    print: function() {}
  },
  // SELENIUM_PROMISE_MANAGER: false,
  onPrepare() {
    require('ts-node').register({
      project: 'e2e/tsconfig.e2e.json'
    });
    jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
    browser.manage().window().setSize(1600, 1000);
    // browser.waitForAngularEnabled(false);
  }
};

WellI have two settings to run the test. One is emulated and the other not emulated. With the emulated the requests are made locally, with the non-emulated they are made to the backend In the emulated context the test take around 90 second to start. Browser is up, show me the home page but start to do it the test 90 second past to start. In the non-emulated context the test take more time for each time to request the backend. This is when start:

here it stop to wait until start the process

And past 90 seconds resolve it in 15 seconds:

finish process

In the non-emulated context, time is greater. But the test ends successfully as well

Aucun commentaire:

Enregistrer un commentaire