/* global beforeAll, afterAll, test, expect */
const webdriver = require('selenium-webdriver')

// Input capabilities
const capabilities = {
  os: 'windows',
  os_version: '10',
  browserName: 'chrome',
  browser_version: 'latest',
  'browserstack.local': 'true',
  build: process.env.BROWSERSTACK_BUILD_NAME,
  project: process.env.BROWSERSTACK_PROJECT_NAME,
  'browserstack.localIdentifier': process.env.BROWSERSTACK_LOCAL_IDENTIFIER,
  'browserstack.user': process.env.BROWSERSTACK_USERNAME,
  'browserstack.key': process.env.BROWSERSTACK_ACCESS_KEY
}

const driver = new webdriver.Builder()
  .usingServer('http://hub-cloud.browserstack.com/wd/hub')
  .withCapabilities(capabilities)
  .build()

beforeAll(async () => {
  // HTTP Server should be running on 8099 port of GitHub runner
  driver.get('http://localhost:8099/test/browser.e2e.html')
}, 20000)

afterAll(async () => {
  await driver.quit()
})

test('test something', async () => {
  const title = await driver.getTitle()
  expect(title).toBe('BrowserStack Tests')
}, 5000)

const webdriver = require('selenium-webdriver')

// Input capabilities
const capabilities = {
  os: 'windows',
  os_version: '10',
  browserName: 'chrome',
  browser_version: 'latest',
  'browserstack.local': 'true',
  build: process.env.BROWSERSTACK_BUILD_NAME,
  project: process.env.BROWSERSTACK_PROJECT_NAME,
  'browserstack.localIdentifier': process.env.BROWSERSTACK_LOCAL_IDENTIFIER,
  'browserstack.user': process.env.BROWSERSTACK_USERNAME,
  'browserstack.key': process.env.BROWSERSTACK_ACCESS_KEY
}

const driver = new webdriver.Builder()
  .usingServer('http://hub-cloud.browserstack.com/wd/hub')
  .withCapabilities(capabilities)
  .build()

// HTTP Server should be running on 8099 port of GitHub runner
driver.get('http://localhost:8099/test/browser.e2e.html').then(function () {
  driver.getTitle().then(function (title) {
    console.log(title)
    driver.quit()
  })
})

--- 
+++ 
@@ -1,4 +1,3 @@
-/* global beforeAll, afterAll, test, expect */
 const webdriver = require('selenium-webdriver')
 
 // Input capabilities
@@ -20,16 +19,10 @@
   .withCapabilities(capabilities)
   .build()
 
-beforeAll(async () => {
-  // HTTP Server should be running on 8099 port of GitHub runner
-  driver.get('http://localhost:8099/test/browser.e2e.html')
-}, 20000)
-
-afterAll(async () => {
-  await driver.quit()
+// HTTP Server should be running on 8099 port of GitHub runner
+driver.get('http://localhost:8099/test/browser.e2e.html').then(function () {
+  driver.getTitle().then(function (title) {
+    console.log(title)
+    driver.quit()
+  })
 })
-
-test('test something', async () => {
-  const title = await driver.getTitle()
-  expect(title).toBe('BrowserStack Tests')
-}, 5000)
Add jest to E2E test
