0

I have a protractor test with the following beforeAll code:

beforeAll(async (done: Function) => {
  await browser.restart();
  await browser.waitForAngularEnabled(false);
  await performLogin('/some_url', LOGIN_EMAIL, LOGIN_PASSWORD);
  await browser.waitForAngularEnabled(true);
  done();
});

The login page is Microsoft Azure Ad, which isn't angular, hence the need to disable waitForAngular().

Sometimes it fails (a problem I am working on). However, when it fails the tests all run, and of course time out because they end up on the login screen.

Is there something I can call in beforeAll() to say "fail every scenario here"?

Justin Dearing
  • 14,270
  • 22
  • 88
  • 161

1 Answers1

1

There's protractor-fail-fast, you can find it here. It basically exits on the first failure, instead of trying to run all tests.

A solution to your particular situation would then be to have the end of your beforeAll() run a verification that the URL is past the login page, something like:

expect(browser.getCurrentUrl()).not.toContain('microsoft.com/login')

If that fails, Protractor will exit right there.

To answer the question in general, you're not the first to be looking for this type of functionality and the Protractor devs are aware of it given that Jasmine now supports it, but it doesn't look like the issue has moved much.

laurentmih
  • 11
  • 3