-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
chore(web): enable testing against legacy devices via BrowserStack #11845
Open
jahorton
wants to merge
17
commits into
master
Choose a base branch
from
chore/web/restore-legacy-auto-testing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+13,124
−8,454
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
d970e0b
chore(web): install dev-deps @web/dev-server-legacy, @web/test-runner…
jahorton 41f4aef
chore(web): restore keyboard-load testing via BrowserStack
jahorton 665cca4
change(web): use function to apply browserstack-specific settings to …
jahorton 4e2b6a1
chore(web): adds configs in other browser-based testing sections
jahorton 018fd4f
chore(web): remove old karma-oriented config
jahorton b8950fd
chore(web): adds --remote option to web build/test scripts that can r…
jahorton a5c1766
chore(web): cntd build-script integration
jahorton 77d075a
feat(web): restore test-timeout scaling for remote testing
jahorton f45d663
fix(web): patches up ci.sh
jahorton 5b9a3f5
chore(web): Merge branch 'master' into chore/web/restore-legacy-auto-…
jahorton 066cc40
Merge branch 'master' into chore/web/restore-legacy-auto-testing
jahorton a68e6fb
chore(web): Merge branch 'master' into chore/web/restore-legacy-auto-…
jahorton dd1aef3
chore(web): Merge remote-tracking branch 'origin/chore/web/restore-le…
jahorton 72e4265
chore(web): test library dev-dependency -> web/package.json
jahorton 4e79184
chore(web): move new files to new post-reorg location
jahorton e8bbf67
chore(web): remove no-longer-needed new file
jahorton a59b9ee
chore(web): update package-lock.json post-merge
jahorton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import * as baseTimeouts from './test-timeouts.mjs'; | ||
|
||
// General pattern, in case more are defined. | ||
const scaledTimeouts = { | ||
...baseTimeouts | ||
}; | ||
Object.keys(baseTimeouts).forEach((key) => scaledTimeouts[key] *= 10); | ||
|
||
export const DEFAULT_BROWSER_TIMEOUT = scaledTimeouts.DEFAULT_BROWSER_TIMEOUT; //ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
import { browserstackLauncher } from '@web/test-runner-browserstack'; | ||
import { legacyPlugin } from '@web/dev-server-legacy'; | ||
import named from '@keymanapp/common-test-resources/test-runner-rename-browser.mjs'; | ||
import { importMapsPlugin } from '@web/dev-server-import-maps'; | ||
|
||
// TODO: always rebuild KEYMAN_VERSION before running this; we want it to show | ||
// the absolute current version in the BrowserStack logs, even if run locally. | ||
import { KEYMAN_VERSION } from '@keymanapp/keyman-version'; | ||
import { defaultReporter, summaryReporter } from '@web/test-runner'; | ||
|
||
// options shared between all browsers | ||
/** @type {Record<string, unknown>} */ | ||
const sharedCapabilities = { | ||
// your username and key for browserstack, you can get this from your browserstack account | ||
// it's recommended to store these as environment variables | ||
'browserstack.user': process.env.BROWSER_STACK_USERNAME, | ||
'browserstack.key': process.env.BROWSER_STACK_ACCESS_KEY, | ||
'browserstack.networkLogs': true, | ||
'browserstack.console': 'verbose', | ||
|
||
project: 'Keyman', | ||
// if you are running tests in a CI, the build id might be available as an | ||
// environment variable. this is useful for identifying test runs | ||
// this is for example the name for github actions | ||
build: `${KEYMAN_VERSION.VERSION_WITH_TAG || '-version tagging broken-'}`, | ||
}; | ||
|
||
/** | ||
* @param {import('@web/test-runner').TestRunnerConfig} config | ||
* @returns {import('@web/test-runner').TestRunnerConfig} | ||
* */ | ||
export function buildLegacyTestingConfig(config, projectName) { | ||
return { | ||
...config, | ||
// how many browsers to run concurrently in browserstack. increasing this significantly | ||
// reduces testing time, but your subscription might limit concurrent connections | ||
concurrentBrowsers: 1, | ||
// amount of test files to execute concurrently in a browser. the default value is based | ||
// on amount of available CPUs locally which is irrelevant when testing remotely | ||
concurrency: 1, | ||
coverage: false, | ||
browsers: [ | ||
// create a browser launcher per browser you want to test | ||
// you can get the browser capabilities from the browserstack website | ||
browserstackLauncher({ | ||
capabilities: { | ||
// Requires the dev-server-legacy plugin to operate properly. | ||
...sharedCapabilities, | ||
// The display name visible on browserstack.com's dashboard | ||
name: projectName || `${KEYMAN_VERSION.VERSION_WITH_TAG}`, | ||
browserName: 'Chrome', | ||
os: 'Windows', | ||
os_version: '10', | ||
/* 57 is our absolute min-version target for 18.0. */ | ||
/* 95 is the highest supported on Android 5.x devices, even when updated. */ | ||
browser_version: '57' | ||
}, | ||
}), | ||
|
||
// macOS... seems to just... time out some of the time. | ||
named(browserstackLauncher({ | ||
capabilities: { | ||
...sharedCapabilities, | ||
name: projectName || `${KEYMAN_VERSION.VERSION_WITH_TAG}`, | ||
browserName: 'Safari', | ||
os: "OS X", | ||
// // ... none of these is actually connecting for remote testing via BrowserStack. | ||
// // No such issue when running the tests locally, though. | ||
os_version: "Catalina", | ||
browser_version: '13.1' | ||
// os_version: "Mojave", | ||
// browser_version: "12.1" | ||
// os_version: "Monterey", | ||
// browser_version: "15.6" | ||
// os_version: "Big Sur", | ||
// browser_version: '14.1' | ||
}, | ||
}), 'Safari'), | ||
|
||
// // iOS devices seem to flake regularly when I attempt to use 'em. | ||
// named(browserstackLauncher({ | ||
// capabilities: { | ||
// ...sharedCapabilities, | ||
// name: projectName || `${KEYMAN_VERSION.VERSION_WITH_TAG}`, | ||
// browserName: 'Safari', | ||
// // '13.4' does not appear to work, nor does '14'. | ||
// // '15', however, does! | ||
// os_version: '15', | ||
// deviceName: 'iPhone SE 2022' | ||
// // os_version: '13.4', | ||
// // deviceName: 'iPhone SE 2020' // 2022 for Safari 15. | ||
// }, | ||
// }), 'Safari for iOS'), | ||
|
||
// was S7, 6.0 - but the API gave us a 'deprecated' report and errored there. | ||
// S8, 7.0 ... seems that the test-process outright crashes for no clearly stated reason? | ||
named(browserstackLauncher({ | ||
capabilities: { | ||
...sharedCapabilities, | ||
name: projectName || `${KEYMAN_VERSION.VERSION_WITH_TAG}`, | ||
browserName: 'Chrome', | ||
os_version: '7.0', | ||
deviceName: 'Samsung Galaxy S8' | ||
}, | ||
}), 'Chrome for Android'), | ||
|
||
// // And sometimes the Firefox test targets flake. Why!? | ||
// browserstackLauncher({ | ||
// capabilities: { | ||
// ...sharedCapabilities, | ||
// name: projectName || `${KEYMAN_VERSION.VERSION_WITH_TAG}`, | ||
// browserName: 'Firefox', | ||
// // 'latest' would work, but not 90. | ||
// // '100' does work, at least. | ||
// browser_version: '100', | ||
// os: 'Windows', | ||
// os_version: '10', | ||
// }, | ||
// }), | ||
], | ||
plugins: [ | ||
...(config.plugins ?? []), | ||
legacyPlugin(), | ||
// Redirects our timeout-defining import to one with more generous | ||
// settings in order to compensate for delays due to serving files | ||
// remotely. | ||
importMapsPlugin({ | ||
inject: { | ||
importMap: { | ||
imports: { | ||
// Note: this cannot resolve a node-style import on the right-hand side. | ||
'@keymanapp/common-test-resources/test-timeouts.mjs': '/common/test/resources/test-timeouts-remote.mjs' | ||
} | ||
} | ||
} | ||
}) | ||
], | ||
|
||
// @web/test-runner uses these settings in their BrowserStack auto-testing. | ||
browserStartTimeout: 1000 * 60 * 2, // * 60 * 2 | ||
testsStartTimeout: 1000 * 60 * 2, | ||
testsFinishTimeout: 1000 * 60 * 2, | ||
|
||
reporters: [...config.reporters, summaryReporter, defaultReporter], | ||
|
||
testFramework: { | ||
...(config.testFramework ?? {}), | ||
config: { | ||
...(config.testFramework?.config ?? {}), | ||
/* remote tunneling for BrowserStack tends to add serious delays to script loads */ | ||
// 2000ms = the Mocha default. | ||
timeout: (config.testFramework?.config?.timeout ?? 2000) * 10 | ||
} | ||
}, | ||
|
||
debug: true | ||
}; | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no
named()
for this one?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like I had it working before, but the names aren't actually showing up from the reporter. So, I didn't bother. 🤷