4

I am running my functional tests using WebdriverIO. I can get the WebdriverIO tests to pass even without async/await. But I read some articles that async/await is the best way of coding javascript to handle promises.

I am new to Javascript and pretty lost on promises. What is the best way to code in WebdriverIO (using async/await, or not | e.g: turn sync off in config and use this?)

The wdio.conf.js config file states the following:

// By default WebdriverIO commands are executed in a synchronous way using
// the wdio-sync package. If you still want to run your tests in an async 
// e.g. using promises you can set the sync option to false.
//
sync: true
iamdanchiv
  • 3,828
  • 4
  • 32
  • 40
user3920295
  • 789
  • 1
  • 11
  • 24
  • 1
    Please, add your code to the question – reisdev Jan 02 '19 at 15:01
  • 1
    I rephrased my question. I am trying to figure out `is using async/await in webdriverio the best way of coding by turning sync off in configuration file or not using it by turning sync on in that file` – user3920295 Jan 02 '19 at 15:08
  • 1
    Don't believe every article you read. If you come from a traditional, sequential programming environment, then stay with `sync: true`. Else, if you want to excel at JS & using Promises, then go `sync: false`. It's just flavor ... w/e *floats your boat*. – iamdanchiv Jan 03 '19 at 07:51

1 Answers1

4

WebdriverIO still uses async/await in the background, it just handles it for you. I'd definitely recommend using 'sync' mode, as it reduces the verbosity of your tests.

Kevin Lamping
  • 2,079
  • 15
  • 19