is not assignable to parameter of type 'Expected<Promise<string>>' in editor

跟風遠走 提交于 2019-12-24 00:44:40

问题


My tests are passing from command line, however I edit the typescript source using Atom.

And when I open one of the test files in my editor, I'm seeing an error on this line:

expect(pageObject.name.getText()).toEqual('Some name');

This is the error:

Typescript

Error
Argument of type '"Some name"' is not assignable to parameter of type 'Expected<Promise<string>>'.at line 16 col 50

Why does this show in my editor? Yet tests pass.

Command to run protractor tests:

protractor dist/protractor.config.js

Snippet from package.json

"dependencies": {
    "typescript": "2.3.3"
},
"devDependencies": {
    "@types/jasmine": "2.5.45",
    "@types/node": "^7.0.13",
    "jasmine-core": "^2.6.0",
    "jasmine-spec-reporter": "^4.1.0",
    "protractor": "^5.1.2"
}

tsconfig.fvt.test.json

{
  "compilerOptions": {
    "module": "commonjs",
    "noImplicitAny": true,
    "noUnusedLocals": true,
    "moduleResolution": "node",
    "sourceMap": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "noUnusedParameters": true,
    "outDir": "dist",
    "skipLibCheck": true,
    "target": "ES5",
    "lib": [
      "dom", "es5", "es6", "scripthost"
    ],
    "types": ["jasmine"]
  },
  "include": [
    "protractor.config.ts",
    "test/e2e/**/*.ts"
  ]
}

回答1:


getText() returns promise. See the doc.

If you want to assert text from an element you need chai-as-promise. See example.



来源:https://stackoverflow.com/questions/44572351/is-not-assignable-to-parameter-of-type-expectedpromisestring-in-editor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!