{"action":"opened","issue":{"url":"https://api.github.com/repos/webdriverio/webdriverio/issues/2955","repository_url":"https://api.github.com/repos/webdriverio/webdriverio","labels_url":"https://api.github.com/repos/webdriverio/webdriverio/issues/2955/labels{/name}","comments_url":"https://api.github.com/repos/webdriverio/webdriverio/issues/2955/comments","events_url":"https://api.github.com/repos/webdriverio/webdriverio/issues/2955/events","html_url":"https://github.com/webdriverio/webdriverio/issues/2955","id":360346310,"node_id":"MDU6SXNzdWUzNjAzNDYzMTA=","number":2955,"title":"v5: using await in a test undoes wdio-sync, commands return promises instead of values","user":{"login":"dylang","id":51505,"node_id":"MDQ6VXNlcjUxNTA1","avatar_url":"https://avatars0.githubusercontent.com/u/51505?v=4","gravatar_id":"","url":"https://api.github.com/users/dylang","html_url":"https://github.com/dylang","followers_url":"https://api.github.com/users/dylang/followers","following_url":"https://api.github.com/users/dylang/following{/other_user}","gists_url":"https://api.github.com/users/dylang/gists{/gist_id}","starred_url":"https://api.github.com/users/dylang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dylang/subscriptions","organizations_url":"https://api.github.com/users/dylang/orgs","repos_url":"https://api.github.com/users/dylang/repos","events_url":"https://api.github.com/users/dylang/events{/privacy}","received_events_url":"https://api.github.com/users/dylang/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-14T15:13:43Z","updated_at":"2018-09-14T15:13:43Z","closed_at":null,"author_association":"NONE","body":"## The problem\r\n\r\nOnce we add any `await`'s, `browser` returns promises instead of values.\r\n\r\n## Environment\r\n\r\n* WebdriverIO version: `5.0.0-beta.2`\r\n* Node.js version: `10`\r\n* Standalone mode or WDIO Testrunner:  `WDIO testrunner but standalone-style?`\r\n```js\r\nimport Launcher from 'wdio-cli';\r\nconst wdio = new Launcher(path.join(__dirname, './wdio.conf'), options);\r\nconst returnCode = await wdio.run();\r\n```\r\n* if wdio testrunner, running synchronous or asynchronous tests: `sync`\r\n* Additional wdio packages used (if applicable): `spec` reporter\r\n\r\n## Details\r\n\r\nSince it seems the recommendation in `v5` is to only use the `sync` API, I'm making that transition, but we would like to still be able to use `async`/`await` in our test code for our Page objects and utility functions. \r\n\r\n## Code To Reproduce Issue\r\n\r\n```js\r\nimport expect from 'expect'; // We prefer expect from Jest over chai\r\n\r\nconst someSetupCode = async () => true;\r\n\r\ndescribe('await breaks wdio-sync', () => {\r\n    it('this works', async () => {\r\n        // no awaits here\r\n        browser.url(process.env.BROWSER_TESTS_BASE_PATH || '/');\r\n        const loaded = $('[data-page-loaded=\"true\"]');\r\n        console.log(loaded); // returns an element despite not being on the page *yet*\r\n        const result = loaded.waitForDisplayed();\r\n        expect(result).toEqual(true);\r\n        // ^ passes as expected!\r\n    });\r\n\r\n    it('this fails because of one await', async () => {\r\n        await someSetupCode();\r\n        // ^^ that await is the only difference\r\n        browser.url(process.env.BROWSER_TESTS_BASE_PATH || '/');\r\n        const loaded = $('[data-page-loaded=\"true\"]');\r\n        console.log(loaded); // returns a promise?!\r\n        const result = loaded.waitForDisplayed();\r\n        // ^^ throws error because loaded.waitForDisplayed is not a function\r\n        expect(result).toEqual(true);\r\n        // ^ never gets here\r\n    });\r\n\r\n    it('this passes but is async', async () => {\r\n        await someSetupCode();\r\n        // ^^ that await is the only difference\r\n        browser.url(process.env.BROWSER_TESTS_BASE_PATH || '/');\r\n        const loaded = await $('[data-page-loaded=\"true\"]');\r\n        //             ^^ added await\r\n        const result = await loaded.waitForDisplayed();\r\n        //             ^^ added await\r\n        expect(result).toEqual(true);\r\n        // ^ now it passes, but why do we need the awaits?\r\n    });\r\n});\r\n```\r\n\r\n\r\n"}}
{"actor":{"display_login":"dylang"}}