Skip to content

Commit

Permalink
chore: apply pre-hook formating
Browse files Browse the repository at this point in the history
  • Loading branch information
byhow committed Jul 30, 2024
1 parent f4b48db commit 7a550c8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
4 changes: 3 additions & 1 deletion tests/globalSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ const prepareUserStorageState = async (baseURL: string, user: User) => {
baseURL,
userAgent: USER_AGENTS[Math.floor(Math.random() * USER_AGENTS.length)],
})
page.addInitScript("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})")
page.addInitScript(
"Object.defineProperty(navigator, 'webdriver', {get: () => undefined})"
)

// login to user
await login({
Expand Down
29 changes: 16 additions & 13 deletions tests/helpers/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,23 @@ export const waitForAPIResponse = async ({
path: string
isOK?: (data: any) => boolean
}) => {
await page.waitForResponse(async (res: Response) => {
try {
const body = (await res.body()).toString()
console.log(`Response body: ${body}`)
const parsedBody = JSON.parse(body)
const data = _get(parsedBody, path)
await page.waitForResponse(
async (res: Response) => {
try {
const body = (await res.body()).toString()
console.log(`Response body: ${body}`)
const parsedBody = JSON.parse(body)
const data = _get(parsedBody, path)

if (isOK(data)) {
return true
if (isOK(data)) {
return true
}
} catch (error) {
console.error(`Response was not waited on ${path} for error: ${error}`)
}
} catch (error) {
console.error(`Response was not waited on ${path} for error: ${error}`)
}

return false
}, { timeout: 15000 })
return false
},
{ timeout: 15000 }
)
}

0 comments on commit 7a550c8

Please sign in to comment.