Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update legacy safari test for GitHub actions #10618

Merged
merged 2 commits into from Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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