简体   繁体   中英

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.

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM