From a8b39889f33524ad1f1a0334d3092e3532a8c313 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Thu, 20 Feb 2020 15:39:57 -0600 Subject: [PATCH] Update legacy safari test for GitHub actions (#10618) --- test/integration/production-nav/test/index.test.js | 14 ++++++-------- test/jest-environment.js | 6 +++++- test/lib/next-webdriver.js | 12 +----------- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/test/integration/production-nav/test/index.test.js b/test/integration/production-nav/test/index.test.js index c1217a6ca6f0946..0583fbfc66b69f0 100644 --- a/test/integration/production-nav/test/index.test.js +++ b/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' @@ -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)) diff --git a/test/jest-environment.js b/test/jest-environment.js index 814798f9600d50a..5e6b56ae236f41e 100644 --- a/test/jest-environment.js +++ b/test/jest-environment.js @@ -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) { diff --git a/test/lib/next-webdriver.js b/test/lib/next-webdriver.js index 9e286b83601bd4d..061328769a4f355 100644 --- a/test/lib/next-webdriver.js +++ b/test/lib/next-webdriver.js @@ -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' @@ -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``