angular / protractor

E2E test framework for Angular apps
http://www.protractortest.org
MIT License
8.75k stars 2.31k forks source link

Typings issue since @types/jasmine update #4176

Open sinedied opened 7 years ago

sinedied commented 7 years ago

Since the release of @types/jasmine@2.5.46 I have this issue while running my protractor tests with typescript:

[18:37:17] E/launcher - Error: TSError: ⨯ Unable to compile TypeScript
e2e/app.e2e-spec.ts (19,45): Argument of type '"Hello world !"' is not assignable to parameter of type 'Expected<Promise<string>>'. (2345)

This trace back to this code:

    expect(page.getParagraphText()).toEqual('Hello world !');

In the new jasmine types, the expect typings are now enforced (it wasn't the case before). It seems that the protractor jasmine overrides that wait for Promises to resolve before performing the match needs to extends the typings for this to work correctly.

Bug report

NickTomlin commented 7 years ago

Thanks for noting this.

Can you pin your types in the meantime to resolve this?

sinedied commented 7 years ago

Sure, it's already done 😉 Thanks for this great tool anyways!

ibqn commented 7 years ago

yep :-(

I also observed this e2e/app.e2e-spec.ts(23,54): error TS2345: Argument of type 'false' is not assignable to parameter of type 'Expected<Promise<boolean>>'.

for the line expect(element(by.css('h1')).isPresent()).toBe(false);

Downgraded jasmine typings to "@types/jasmine": "2.5.45"

ChristianStornowski commented 7 years ago

For Jasmine tests you can use @types/jasminewd2 additionally to @types/jasmine.

raghulrajnkl commented 7 years ago

expect( to expect(

its worked for me

sinedied commented 7 years ago

@ChristianStornowski still not working even with @types/jasminewd2

ChristianStornowski commented 7 years ago

Here are my settings for package.json

... "devDependencies": { ... "@types/jasmine": "^2.5.52", "@types/jasminewd2": "^2.0.2", "jasmine-core": "^2.6.4", "typescript": "^2.3.4", ... } ...

for tsconfig.json

{ "compilerOptions": { "target": "es5", "module": "CommonJS", "moduleResolution": "Node", "emitDecoratorMetadata": true, "experimentalDecorators": true, "noImplicitAny": true, "suppressImplicitAnyIndexErrors": true, "outDir": "build", "strictNullChecks": true, "lib": [ "DOM", "ES5", "ES6", "ES7", "DOM.Iterable", "ScriptHost" ] } }

This is working with current IntellIJ for me.

sinedied commented 7 years ago

@ChristianStornowski Thanks, I found why it wasn't working!

I'm using angular-cli and the default e2e package.json config has:

    "types": [
      "jasmine",
      "node"
    ]

changing it to:

    "types": [
      "jasmine",
      "jasminewd2",
      "node"
    ]

make it work!

mruzek commented 6 years ago

Any updates after 13 months guys ?

devoto13 commented 6 years ago

@mruzek What kind of update do you expect? There is nothing broken here.

You have two options: