Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
CM-921: Improving BS tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya committed Aug 31, 2023
1 parent 0012579 commit fb12bd9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 44 deletions.
6 changes: 6 additions & 0 deletions test-config/wdio.browserstack.conf.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import commonConfig from './wdio.common.conf.js'
import http from 'http';
import https from 'https';
const currentTime = Date.now()
const commonBStackCapabilities = {
projectName: 'LiveConnect',
Expand Down Expand Up @@ -94,6 +96,10 @@ export const config = {
key: process.env.BS_KEY,
hostname: 'hub.browserstack.com',

agent: {
http: new http.Agent({ keepAlive: true }),
https: new https.Agent({ keepAlive: true })
},
//
// The number of times to retry the entire specfile when it fails as a whole
specFileRetries: 2
Expand Down
27 changes: 1 addition & 26 deletions test/it/helpers/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,32 +162,7 @@ export async function probeLS() {
return enabled
}

export async function deleteAllCookies() {
const error = await browser.execute(() => {
try {
const cookies = document.cookie.split('; ')
for (let c = 0; c < cookies.length; c++) {
const d = window.location.hostname.split('.')
while (d.length > 0) {
const cookieBase = encodeURIComponent(cookies[c].split(';')[0].split('=')[0]) + '=; expires=Thu, 01-Jan-1970 00:00:01 GMT; domain=' + d.join('.') + ' ;path='
const p = location.pathname.split('/')
document.cookie = cookieBase + '/'
while (p.length > 0) {
document.cookie = cookieBase + p.join('/')
p.pop()
}
d.shift()
}
}
return null
} catch (e) {
return e
}
})
if (error) {
console.error(`failed cleaning cookies: ${error}`)
}
}
export const deleteAllCookies = () => browser.deleteAllCookies()

export function isMobileSafari() {
return browser.capabilities.browserName === 'safari' &&
Expand Down
20 changes: 5 additions & 15 deletions test/it/helpers/mock-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,21 +207,11 @@ export function MockServerFactory(config) {
const afterPage = await getText('#after')
assert.strictEqual(afterPage, 'After')
},
getHistory: () => {
return history
},
getIdexHistory: () => {
return idex
},
getBakerHistory: () => {
return bakerHistory
},
getTrackingRequests: () => {
return history.filter(req => req.query.ae === undefined)
},
getApplicationErrors: () => {
return history.filter(req => req.query.ae !== undefined)
},
getHistory: () => history,
getIdexHistory: () => idex,
getBakerHistory: () => bakerHistory,
getTrackingRequests: () => history.filter(req => req.query.ae === undefined),
getApplicationErrors: () => history.filter(req => req.query.ae !== undefined),
clearHistory: () => {
idex = []
history = []
Expand Down
4 changes: 1 addition & 3 deletions test/it/live-connect.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ describe('LiveConnect', function () {
console.log('\x1b[35m\x1b[4m%s\x1b[0m', `##### Finishing the test: '${this.currentTest.fullTitle()}'`)
})

after(function () {
server.stop()
})
after(() => server.stop())

it('should send decisionIds', async function () {
const decisionIdOne = '4ca76883-1e26-3fb8-b6d1-f881ac7d6699'
Expand Down

0 comments on commit fb12bd9

Please sign in to comment.