mercredi 25 mars 2020

Protractor for Angular : Wait for HTTP requests to finish before continuing the script

When I run my E2E testing script using protractor, the thing I do is that I do many browser.sleep(xxxx) to wait a moment for all HTTP requests (GET, POST, PUT,...) to end, because otherwise if I don't do this protractor does not wait and I can't do and test what I want to test in my angular application.

So is there a way to make sure that the script will not continue until all HTTP requests are no longer in status pending ?

My config file :

allScriptsTimeout: 11000,
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: [
    './e2e/**/*.e2e-spec.ts'
  ],
  capabilities: {
    'browserName': 'firefox'
  },
  directConnect: true,
  baseUrl: 'http://localhost:4200/',
  framework: 'jasmine',
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000,
    print: function() {}
  },
  onPrepare() {
    require('ts-node').register({
      project: 'e2e/tsconfig.e2e.json'
    });
    jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
  }

Aucun commentaire:

Enregistrer un commentaire