Skip to content

Commit

Permalink
Update legacy safari test for GitHub actions (#10618)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Feb 20, 2020
1 parent 3cd45bc commit a8b3988
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
14 changes: 6 additions & 8 deletions test/integration/production-nav/test/index.test.js
@@ -1,12 +1,7 @@
/* eslint-env jest */
/* global jasmine */
import {
nextBuild,
findPort,
nextStart,
killApp,
waitFor,
} from 'next-test-utils'
import { nextBuild, nextStart, killApp, waitFor } from 'next-test-utils'
import getPort from 'get-port'
import webdriver from 'next-webdriver'
import { join } from 'path'

Expand All @@ -18,7 +13,10 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 1
describe('Production Usage', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
// use compatible port: https://www.browserstack.com/question/664
appPort = await getPort({
port: [8080, 8081, 8888, 8899],
})
app = await nextStart(appDir, appPort)
})
afterAll(() => killApp(app))
Expand Down
6 changes: 5 additions & 1 deletion test/jest-environment.js
Expand Up @@ -76,7 +76,11 @@ class CustomEnvironment extends NodeEnvironment {
this.server.close()
}
if (this.global.wd) {
await this.global.wd.quit()
try {
await this.global.wd.quit()
} catch (err) {
console.log(`Failed to quit webdriver instance`, err)
}
}
// must come after wd.quit()
if (this.seleniumServer) {
Expand Down
12 changes: 1 addition & 11 deletions test/lib/next-webdriver.js
Expand Up @@ -105,16 +105,6 @@ let browser = new Builder()

global.wd = browser

/*
# Methods to match
- elementByCss
- elementsByCss
- waitForElementByCss
- elementByCss.text
- elementByCss.click
*/

let initialWindow
let deviceIP = 'localhost'

Expand Down Expand Up @@ -166,7 +156,7 @@ export default async (appPort, path, waitHydration = true) => {
if (!initialWindow) {
initialWindow = await browser.getWindowHandle()
}
if (isBrowserStack && deviceIP === 'localhost') {
if (isBrowserStack && deviceIP === 'localhost' && !LEGACY_SAFARI) {
await getDeviceIP()
}
// browser.switchTo().window() fails with `missing field `handle``
Expand Down

0 comments on commit a8b3988

Please sign in to comment.