Skip to content

Commit

Permalink
feat: add type of test in result and export always on success or error
Browse files Browse the repository at this point in the history
  • Loading branch information
Ando committed May 22, 2024
1 parent 0b24d14 commit c5e474b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
13 changes: 12 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,15 @@ const caseStatus: Record<string, string> = {
failed: 'failed',
}

export { caseStatus, driverBrowserList, driverBrowsers, seleniumExceptions }
const dataResultType: Record<string, string> = {
object: 'object',
function: 'function',
}

export {
caseStatus,
dataResultType,
driverBrowserList,
driverBrowsers,
seleniumExceptions,
}
29 changes: 19 additions & 10 deletions src/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type {
import { getCurrentMonth, isValidHttpUrl } from '@pkg/utils.ts'
import {
caseStatus,
dataResultType,
driverBrowserList,
driverBrowsers,
seleniumExceptions,
Expand Down Expand Up @@ -97,6 +98,7 @@ const driver = async (
duration,
timestamp,
month_of_test,
type,
browser,
}: TDataResult,
) => {
Expand All @@ -109,6 +111,7 @@ const driver = async (
timestamp,
duration,
month_of_test,
type,
browser,
}
}
Expand Down Expand Up @@ -144,6 +147,7 @@ const driver = async (
timestamp: new Date(),
duration: end - start,
month_of_test: month,
type: dataResultType.object,
browser,
}),
)
Expand All @@ -161,6 +165,7 @@ const driver = async (
timestamp: new Date(),
duration: end - start,
month_of_test: month,
type: dataResultType.object,
browser,
}),
)
Expand Down Expand Up @@ -221,6 +226,7 @@ const driver = async (
timestamp: new Date(),
duration: end - start,
month_of_test: month,
type: dataResultType.object,
browser,
}),
)
Expand All @@ -238,6 +244,7 @@ const driver = async (
timestamp: new Date(),
duration: end - start,
month_of_test: month,
type: dataResultType.object,
browser,
}),
)
Expand All @@ -256,17 +263,19 @@ const driver = async (
}
})(5)

Promise.all(methodPromises)
.then(() => {
if (exportPdf) exportGeneratedPdf({ results: data.results })
exportGeneratedLog({ results: data.results })
exportJSONReport({
results: data.results,
flakyTests: flakyCases,
browser,
})
const exportGeneratedFiles = () => {
if (exportPdf) exportGeneratedPdf({ results: data.results })
exportGeneratedLog({ results: data.results })
exportJSONReport({
results: data.results,
flakyTests: flakyCases,
browser,
})
.catch((error) => reject(error)).finally(() => {
}

Promise.all(methodPromises)
.then(() => exportGeneratedFiles())
.catch(() => exportGeneratedFiles()).finally(() => {
kia.succeed(`All tests completed on ${browser}`)
builder.quit()
})
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export type TDataResult = {
timestamp: Date
duration: number
month_of_test: string
type: string
browser: TDriverBrowser
}

Expand Down

0 comments on commit c5e474b

Please sign in to comment.