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

chore(web): enable testing against legacy devices via BrowserStack #11845

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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 Jun 25, 2024
41f4aef
chore(web): restore keyboard-load testing via BrowserStack
jahorton Jun 25, 2024
665cca4
change(web): use function to apply browserstack-specific settings to …
jahorton Jun 25, 2024
4e2b6a1
chore(web): adds configs in other browser-based testing sections
jahorton Jun 25, 2024
018fd4f
chore(web): remove old karma-oriented config
jahorton Jun 25, 2024
b8950fd
chore(web): adds --remote option to web build/test scripts that can r…
jahorton Aug 12, 2024
a5c1766
chore(web): cntd build-script integration
jahorton Aug 13, 2024
77d075a
feat(web): restore test-timeout scaling for remote testing
jahorton Aug 13, 2024
f45d663
fix(web): patches up ci.sh
jahorton Aug 13, 2024
5b9a3f5
chore(web): Merge branch 'master' into chore/web/restore-legacy-auto-…
jahorton Aug 15, 2024
066cc40
Merge branch 'master' into chore/web/restore-legacy-auto-testing
jahorton Aug 15, 2024
a68e6fb
chore(web): Merge branch 'master' into chore/web/restore-legacy-auto-…
jahorton Aug 21, 2024
dd1aef3
chore(web): Merge remote-tracking branch 'origin/chore/web/restore-le…
jahorton Aug 21, 2024
72e4265
chore(web): test library dev-dependency -> web/package.json
jahorton Aug 21, 2024
4e79184
chore(web): move new files to new post-reorg location
jahorton Aug 21, 2024
e8bbf67
chore(web): remove no-longer-needed new file
jahorton Aug 21, 2024
a59b9ee
chore(web): update package-lock.json post-merge
jahorton Aug 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 0 additions & 159 deletions common/test/resources/karma-browserstack-config.cjs

This file was deleted.

9 changes: 9 additions & 0 deletions common/test/resources/test-runner-TC-reporter.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,18 @@ export default function teamcityReporter({ name="Web Test Runner JavaScript test

for(const sessionName of sessionFailureMap.keys()) {
const sessionTestData = testDefMap.get(sessionName);
const session = args.sessions.find((entry) => buildSessionName(entry) == sessionName);

logger.log('');
logger.log(`Failure data for '${sessionName}'`);

if(session.errors) {
for(let error of session.errors) {
// "Browser tests did not start after xxxx ms..."" errors appear here.
logger.error(` ${error.message}`);
}
}

for(const sessionFile of sessionFailureMap.get(sessionName)) {
const testFile = sessionFile.testFile;
const fileTestData = sessionTestData.get(testFile);
Expand Down
9 changes: 9 additions & 0 deletions common/test/resources/test-timeouts-remote.mjs
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
158 changes: 158 additions & 0 deletions common/test/resources/wtr-browserstack-config.mjs
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({
Copy link
Contributor

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?

Copy link
Contributor Author

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. 🤷

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
};
};
Loading
Loading