altschuler
altschuler

Reputation: 3922

Angular 2 (cli) protractor jasmine expect is not resolving promise

I am writing E2E tests with Protractor and Angular 2 using Jasmine.

I am trying to do a simple expectation on the getText() of an element returned by protractor.

it('should display correct hero title', () => {
    expect(element(by.css('Hero-title')).getText()).toEqual('Foobar');
});

This results in a type error:

Argument of type '"Foobar"' is not assignable to parameter of type 'Expected<Promise<string>>'. [2345]

I know I could use .then but I don't want to do that as I will have loads of these types of expectations.

Using a fresh Angular CLI project this works as expected. I have gone through all the configs but cannot find any differences.

Upvotes: 4

Views: 736

Answers (1)

alecxe
alecxe

Reputation: 474281

This relates to jasmine, starting with 2.5.46, enforcing correct typings, here is a related open issue in the Protractor issue tracker:

As a workaround, you can pin your "jasmine types" version to 2.5.45 until the issue is fixed:

"@types/jasmine": "2.5.45"

Upvotes: 5

Related Questions