diff --git a/trackers/javascript-tracker/test/functional/activityCallback.test.ts b/trackers/javascript-tracker/test/functional/activityCallback.test.ts index 79d4a22ba..0a5e9fb84 100644 --- a/trackers/javascript-tracker/test/functional/activityCallback.test.ts +++ b/trackers/javascript-tracker/test/functional/activityCallback.test.ts @@ -9,8 +9,9 @@ declare var findFirstEventForPageViewId: (id: string) => Record declare var findLastEventForPageViewId: (id: string) => Record; describe('Activity tracking with callbacks', () => { - if (browser.capabilities.browserName === 'internet explorer') { - fit('Skip IE', () => true); + const browserName = 'browserName' in browser.capabilities && browser.capabilities.browserName; + if (browserName === 'internet explorer') { + fit('Skip IE', () => {}); return; } diff --git a/trackers/javascript-tracker/test/integration/buttonClick.test.ts b/trackers/javascript-tracker/test/integration/buttonClick.test.ts index bacaed1cf..c5c276f36 100644 --- a/trackers/javascript-tracker/test/integration/buttonClick.test.ts +++ b/trackers/javascript-tracker/test/integration/buttonClick.test.ts @@ -11,8 +11,9 @@ const loadUrlAndWait = async (url: string) => { }; describe('Snowplow Micro integration', () => { - if (browser.capabilities.browserName === 'internet explorer') { - fit('Skip IE', () => true); + const browserName = 'browserName' in browser.capabilities && browser.capabilities.browserName; + if (browserName === 'internet explorer') { + fit('Skip IE', () => {}); return; } diff --git a/trackers/javascript-tracker/test/integration/helpers.ts b/trackers/javascript-tracker/test/integration/helpers.ts index e71d298ca..7f0d95f97 100644 --- a/trackers/javascript-tracker/test/integration/helpers.ts +++ b/trackers/javascript-tracker/test/integration/helpers.ts @@ -1,5 +1,6 @@ import { WaitUntilOptions } from 'webdriverio'; import util from 'util'; +import { Capabilities } from '@wdio/types'; declare module WebdriverIO { interface Browser { @@ -48,8 +49,8 @@ export async function pageSetup() { if (!dockerUrl) { throw 'dockerInstanceUrl not available in `browser.sharedStore`'; } - const testIdentifier = - browser.capabilities.browserName + '_' + browser.capabilities.browserVersion + '_' + Math.random(); + const capabilities = browser.capabilities as Capabilities.DesiredCapabilities; + const testIdentifier = capabilities.browserName + '_' + capabilities.browserVersion + '_' + Math.random(); await browser.url('/index.html'); await browser.setCookies([ { name: 'container', value: dockerUrl }, diff --git a/trackers/javascript-tracker/test/integration/integration.test.ts b/trackers/javascript-tracker/test/integration/integration.test.ts index 28ba0966c..d3725a6ff 100755 --- a/trackers/javascript-tracker/test/integration/integration.test.ts +++ b/trackers/javascript-tracker/test/integration/integration.test.ts @@ -35,8 +35,9 @@ const geoContext = { }; describe('Snowplow Micro integration', () => { - if (browser.capabilities.browserName === 'internet explorer') { - fit('Skip IE', () => true); + const browserName = 'browserName' in browser.capabilities && browser.capabilities.browserName; + if (browserName === 'internet explorer') { + fit('Skip IE', () => {}); return; } diff --git a/trackers/javascript-tracker/test/integration/onSessionUpdate.test.ts b/trackers/javascript-tracker/test/integration/onSessionUpdate.test.ts index 9e77fd8e4..0e7fc4745 100644 --- a/trackers/javascript-tracker/test/integration/onSessionUpdate.test.ts +++ b/trackers/javascript-tracker/test/integration/onSessionUpdate.test.ts @@ -1,18 +1,20 @@ import F from 'lodash/fp'; import { fetchResults } from '../micro'; import { pageSetup } from './helpers'; +import { Capabilities } from '@wdio/types'; describe('onSessionUpdate callback feature', () => { + const capabilities = browser.capabilities as Capabilities.DesiredCapabilities; if ( - browser.capabilities.browserName === 'internet explorer' && - (browser.capabilities.version === '9' || browser.capabilities.browserVersion === '10') + capabilities.browserName === 'internet explorer' && + (capabilities.version === '9' || capabilities.browserVersion === '10') ) { - fit('Skip IE 9 and 10', () => true); + fit('Skip IE 9 and 10', () => {}); return; } - if (browser.capabilities.browserName === 'safari' && browser.capabilities.version === '8.0') { - fit('Skip Safari 8', () => true); + if (capabilities.browserName === 'safari' && capabilities.version === '8.0') { + fit('Skip Safari 8', () => {}); return; } diff --git a/trackers/javascript-tracker/test/media/media.test.ts b/trackers/javascript-tracker/test/media/media.test.ts index a890669d9..dd57f12d9 100644 --- a/trackers/javascript-tracker/test/media/media.test.ts +++ b/trackers/javascript-tracker/test/media/media.test.ts @@ -1,6 +1,7 @@ import _ from 'lodash'; import { fetchResults } from '../micro'; import { pageSetup, waitUntil } from '../integration/helpers'; +import { Capabilities } from '@wdio/types'; const playVideoElement1Callback = () => { return (done: (_: void) => void) => { @@ -102,7 +103,8 @@ const makeExpectedEvent = ( }, }; - if (browser.capabilities.browserName === 'internet explorer') { + const browserName = 'browserName' in browser.capabilities && browser.capabilities.browserName; + if (browserName === 'internet explorer') { data.context[0].data.defaultMuted = false; } @@ -151,16 +153,17 @@ describe('Media Tracking', () => { } }; + const capabilities = browser.capabilities as Capabilities.DesiredCapabilities; if ( - browser.capabilities.browserName === 'internet explorer' && - (browser.capabilities.version === '9' || browser.capabilities.browserVersion === '10') + capabilities.browserName === 'internet explorer' && + (capabilities.version === '9' || capabilities.browserVersion === '10') ) { - fit('Skip IE 9 and 10', () => true); + fit('Skip IE 9 and 10', () => {}); return; } - if (browser.capabilities.browserName === 'safari' && browser.capabilities.version === '8.0') { - fit('Skip Safari 8', () => true); + if (capabilities.browserName === 'safari' && capabilities.version === '8.0') { + fit('Skip Safari 8', () => {}); return; } @@ -515,13 +518,14 @@ describe('Media Tracking', () => { Object.entries(expected).forEach(([name, properties]) => { // I can't find a good way of triggering an error event for firefox 53 or chrome 60, so they can // be skipped for now (events past 'error' are fired as a result of the error occouring) + const capabilities = browser.capabilities as Capabilities.DesiredCapabilities; if ( (name === 'error' && - browser.capabilities.browserName === 'firefox' && - browser.capabilities.browserVersion === '53.0') || - (browser.capabilities.browserName === 'chrome' && browser.capabilities.version === '60.0.3112.78') + capabilities.browserName === 'firefox' && + capabilities.browserVersion === '53.0') || + (capabilities.browserName === 'chrome' && capabilities.version === '60.0.3112.78') ) { - fit('Skip events from error', () => true); + fit('Skip events from error', () => {}); return; } else { it('tracks ' + name, () => { diff --git a/trackers/javascript-tracker/test/media/vimeo.test.ts b/trackers/javascript-tracker/test/media/vimeo.test.ts index d028fb3ea..4dab0a53d 100644 --- a/trackers/javascript-tracker/test/media/vimeo.test.ts +++ b/trackers/javascript-tracker/test/media/vimeo.test.ts @@ -1,6 +1,7 @@ import { VimeoEvent } from '@snowplow/browser-plugin-vimeo-tracking'; import { pageSetup } from '../integration/helpers'; import { fetchResults } from '../micro'; +import { Capabilities } from '@wdio/types'; function compareContextObjects(expected: any, received: any) { expect(expected.schema).toEqual(received.schema); @@ -51,37 +52,38 @@ const makeContext = () => { }; const skipBrowsers = (browser: any) => { - if (browser.capabilities.browserName === 'internet explorer' && browser.capabilities.version === '9') { - fit('Skip IE 9', () => true); + const capabilities = browser.capabilities as Capabilities.DesiredCapabilities; + if (capabilities.browserName === 'internet explorer' && capabilities.version === '9') { + fit('Skip IE 9', () => {}); return; } - if (browser.capabilities.browserName === 'internet explorer' && browser.capabilities.browserVersion === '10') { - fit('Skip IE 10', () => true); + if (capabilities.browserName === 'internet explorer' && capabilities.browserVersion === '10') { + fit('Skip IE 10', () => {}); return; } // element not interactable: Element is not displayed - if (browser.capabilities.browserName === 'internet explorer' && browser.capabilities.browserVersion === '11') { - fit('Skip IE 11', () => true); + if (capabilities.browserName === 'internet explorer' && capabilities.browserVersion === '11') { + fit('Skip IE 11', () => {}); return; } // Unknown command: {"name":"sendKeysToActiveElement","parameters":{"value":["k"]}} - if (browser.capabilities.browserName === 'safari' && browser.capabilities.version === '8.0') { - fit('Skip Safari 8', () => true); + if (capabilities.browserName === 'safari' && capabilities.version === '8.0') { + fit('Skip Safari 8', () => {}); return; } // Element is obscured (WARNING: The server did not provide any stacktrace information) - if (browser.capabilities.browserName === 'MicrosoftEdge' && browser.capabilities.browserVersion === '13.10586') { - fit('Skip Edge 13', () => true); + if (capabilities.browserName === 'MicrosoftEdge' && capabilities.browserVersion === '13.10586') { + fit('Skip Edge 13', () => {}); return; } // Driver info: driver.version: unknown - if (browser.capabilities.browserName === 'firefox' && browser.capabilities.version === '53.0') { - fit('Skip Firefox 53', () => true); + if (capabilities.browserName === 'firefox' && capabilities.version === '53.0') { + fit('Skip Firefox 53', () => {}); return; } }; diff --git a/trackers/javascript-tracker/test/media/youtube.test.ts b/trackers/javascript-tracker/test/media/youtube.test.ts index 9647e7b78..963ce868f 100644 --- a/trackers/javascript-tracker/test/media/youtube.test.ts +++ b/trackers/javascript-tracker/test/media/youtube.test.ts @@ -1,5 +1,6 @@ import { fetchResults } from '../micro'; import { pageSetup, waitUntil } from '../integration/helpers'; +import { Capabilities } from '@wdio/types'; declare var player: YT.Player; @@ -67,14 +68,15 @@ const compare = (expected: any, received: any) => { let log: Array = []; function shouldSkipBrowser(browser: any): boolean { + const capabilities = browser.capabilities as Capabilities.DesiredCapabilities; return ( - browser.capabilities.browserName === 'internet explorer' || + capabilities.browserName === 'internet explorer' || // Unknown command: {"name":"sendKeysToActiveElement","parameters":{"value":["k"]}}, Safari 12 keeps crashing - (browser.capabilities.browserName === 'safari' && browser.capabilities.browserVersion < 14) || + (capabilities.browserName === 'safari' && parseInt(capabilities.browserVersion ?? "") < 14) || // Element is obscured (WARNING: The server did not provide any stacktrace information) - (browser.capabilities.browserName === 'MicrosoftEdge' && browser.capabilities.browserVersion === '13.10586') || + (capabilities.browserName === 'MicrosoftEdge' && capabilities.browserVersion === '13.10586') || // Driver info: driver.version: unknown - (browser.capabilities.browserName === 'firefox' && browser.capabilities.version === '53.0') + (capabilities.browserName === 'firefox' && capabilities.version === '53.0') ); } @@ -112,7 +114,7 @@ describe('Youtube tracking', () => { describe('YouTube Tracker', () => { if (shouldSkipBrowser(browser)) { - fit('Skip browser', () => true); + fit('Skip browser', () => {}); return; } @@ -188,13 +190,14 @@ describe('Youtube tracking', () => { }; Object.entries(expected).forEach(([name, properties]) => { - if (browser.capabilities.browserName === 'internet explorer' && name === 'playbackratechange') { + const capabilities = browser.capabilities as Capabilities.DesiredCapabilities; + if (capabilities.browserName === 'internet explorer' && name === 'playbackratechange') { return; // The hotkey for playback rate change doesn't work in IE // Trying to create a key sequence to change the option in the UI has proved to be // very unreliable, so this test is skipped } - if (browser.capabilities.browserName === 'safari' && name == 'percentprogress') { + if (capabilities.browserName === 'safari' && name == 'percentprogress') { return; // percentprogress events seem not be tracked reliably in Safari, should investigate why } @@ -208,7 +211,7 @@ describe('Youtube tracking', () => { describe('YouTube Tracker (2 videos, 1 tracker)', () => { if (shouldSkipBrowser(browser)) { - fit('Skip browser', () => true); + fit('Skip browser', () => {}); return; } @@ -251,7 +254,7 @@ describe('Youtube tracking', () => { describe('YouTube Tracker (1 video, 2 trackers)', () => { if (shouldSkipBrowser(browser)) { - fit('Skip browser', () => true); + fit('Skip browser', () => {}); return; }