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

feat: use sample of data set to metrics #68

Merged
merged 1 commit into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
109 changes: 104 additions & 5 deletions src/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const exportJSONReport = (
Deno.createSync(filePath)
writeJsonSync(filePath, {
drowser: {
metrics: {},
cases: [],
},
}, { spaces: 2 })
Expand All @@ -102,18 +103,116 @@ const exportJSONReport = (
const jsonData = readJsonSync(filePath) as TJSON

const month = new Date().toLocaleString('default', { month: 'short' })
console.log(month)

jsonData.drowser.metrics = {
total_tests: 10,
passing_tests: 13,
failed_tests: 100,
test_coverage: 23,
avg_test_duration: 2,
flaky_tests: 23,
graphs: {
total_tests: [
{
id: 'Totals',
data: [
{ x: 'Jan', y: 43 },
{ x: 'Feb', y: 137 },
{ x: 'Mar', y: 61 },
{ x: 'Apr', y: 145 },
{ x: 'May', y: 26 },
{ x: 'Jun', y: 154 },
{ x: 'Jun', y: 72 },
{ x: 'Jul', y: 111 },
{ x: 'Aug', y: 157 },
{ x: 'Sep', y: 129 },
{ x: 'Oct', y: 150 },
{ x: 'Nov', y: 119 },
{ x: 'Dec', y: 72 },
],
},
],
passing_tests: [
{ name: 'Jan', count: 111 },
{ name: 'Feb', count: 157 },
{ name: 'Mar', count: 129 },
{ name: 'Apr', count: 150 },
{ name: 'May', count: 119 },
{ name: 'Jun', count: 72 },
{ name: 'Jul', count: 111 },
{ name: 'Aug', count: 157 },
{ name: 'Sep', count: 129 },
{ name: 'Oct', count: 150 },
{ name: 'Nov', count: 119 },
{ name: 'Dec', count: 72 },
],
failed_tests: [
{ name: 'Jan', count: 111 },
{ name: 'Feb', count: 157 },
{ name: 'Mar', count: 129 },
{ name: 'Apr', count: 150 },
{ name: 'May', count: 119 },
{ name: 'Jun', count: 72 },
{ name: 'Jul', count: 111 },
{ name: 'Aug', count: 157 },
{ name: 'Sep', count: 129 },
{ name: 'Oct', count: 150 },
{ name: 'Nov', count: 119 },
{ name: 'Dec', count: 72 },
],
test_coverage: [
{ name: 'Jan', count: 111 },
{ name: 'Feb', count: 157 },
{ name: 'Mar', count: 129 },
{ name: 'Apr', count: 150 },
{ name: 'May', count: 119 },
{ name: 'Jun', count: 72 },
{ name: 'Jul', count: 111 },
{ name: 'Aug', count: 157 },
{ name: 'Sep', count: 129 },
{ name: 'Oct', count: 150 },
{ name: 'Nov', count: 119 },
{ name: 'Dec', count: 72 },
],
avg_test_duration: [
{ name: 'Jan', count: 111 },
{ name: 'Feb', count: 157 },
{ name: 'Mar', count: 129 },
{ name: 'Apr', count: 150 },
{ name: 'May', count: 119 },
{ name: 'Jun', count: 72 },
{ name: 'Jul', count: 111 },
{ name: 'Aug', count: 157 },
{ name: 'Sep', count: 129 },
{ name: 'Oct', count: 150 },
{ name: 'Nov', count: 119 },
{ name: 'Dec', count: 72 },
],
flaky_tests: [
{ id: 'Jan', value: 111 },
{ id: 'Feb', value: 157 },
{ id: 'Mar', value: 129 },
{ id: 'Apr', value: 150 },
{ id: 'May', value: 119 },
{ id: 'Jun', value: 72 },
{ id: 'Jun', value: 72 },
{ id: 'Jul', value: 111 },
{ id: 'Aug', value: 157 },
{ id: 'Sep', value: 129 },
{ id: 'Oct', value: 150 },
{ id: 'Nov', value: 119 },
{ id: 'Dec', value: 72 },
],
},
}

jsonData.drowser.cases.push({
id: nanoid(),
time: new Date().toISOString(),
avg_duration: getAverageDuration({ results }),
coverage: getCoverage({ results }),
flaky: getFlaky({ flakyTests }),
metrics: {
total_tests: {
[month]: results.length,
},
},
cases: results,
})

Expand Down
37 changes: 36 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,51 @@ export type TIsValidHttpUrlParams = {
url: string
}

export type DataPoint = {
x: string
y: number
}

export type DataSet = {
id: string
data: DataPoint[]
}

export type MonthCount = {
name: string
count: number
}

export type MonthValue = {
id: string
value: number
}

export type TJSON = {
drowser: {
metrics: {
total_tests: number
passing_tests: number
failed_tests: number
test_coverage: number
avg_test_duration: number
flaky_tests: number
graphs: {
total_tests: DataSet[]
passing_tests: MonthCount[]
failed_tests: MonthCount[]
test_coverage: MonthCount[]
avg_test_duration: MonthCount[]
flaky_tests: MonthValue[]
}
}
cases: [
{
id: string
time: string
avg_duration: number
coverage: number
flaky: number
metrics: Record<string, any>
cases: Array<TDataResult>
},
]
Expand Down
Loading