Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Handle UncaughtPromiseRejection events #5051

Open
heathkit opened this issue Nov 21, 2018 · 3 comments
Open

Handle UncaughtPromiseRejection events #5051

heathkit opened this issue Nov 21, 2018 · 3 comments

Comments

@heathkit
Copy link
Contributor

If a webdriver command isn't properly awaited or promise chained and has an error, it'll throw an UncaughtPromiseRejection event. We should catch these events and log an error telling the user that they likely missed an await somewhere. Bonus points if we can get a stacktrace to the exact line that wasn't awaited.

@cnishina cnishina added this to the selenium4 upgrade milestone Nov 28, 2018
@cnishina cnishina self-assigned this Nov 28, 2018
@cnishina cnishina added the P1 label Nov 29, 2018
@cnishina
Copy link
Contributor

The unhandledPromiseRejection exists but I am unable to get to this condition.

@cnishina
Copy link
Contributor

Actually was able to reproduce this in #5095 and have a better message set.

@cnishina
Copy link
Contributor

describe('protractor with typescript typings', () => {
  it('sync works', () => {
    expect(1).toEqual(2);
    expect(3).toEqual(2);
  });

  it('async doesn\'t', async () => {
    expect(1).toEqual(2);
  });
});

config:

import {Config} from 'protractor';

export let config: Config = {
  framework: 'jasmine',
  capabilities: {
    browserName: 'chrome'
  },
  specs: [ 'spec.js' ],
  seleniumAddress: 'http://localhost:4444/wd/hub',
  onPrepare: () => {
    jasmine.getEnv().throwOnExpectationFailure(true);
  },
  // You could set no globals to true to avoid jQuery '$' and protractor '$'
  // collisions on the global namespace.
  noGlobals: true
};

Might be worth investigating before closing this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants