Skip to content

Commit

Permalink
Add test coverage md doc (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shubhabrata08 authored Feb 17, 2024
1 parent 90e3762 commit 6a2e25a
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/docsite/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const sidebars: SidebarsConfig = {
'implementing-2-to-1-spacing',
'creating-date-objects-for-chart-data',
'Testing Strategy',
'TestCoverage',
{
type:'category',
label:'Test Plans',
Expand Down
48 changes: 48 additions & 0 deletions apps/docsite/src/components/GetCoverageJSON.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React, { useEffect, useState } from "react";

interface GetCoverageJSONProps{
OS:string
}
const GetCoverageJSON: React.FC<GetCoverageJSONProps> = ({OS}) => {
const [coverage, setCoverage] = useState<number | undefined>();
const [errorState, setErrorState] = useState<Error | undefined>();

useEffect(() => {
const fetchData = async () => {
try {
const data = await fetch(
"https://proud-island-067885010.4.azurestaticapps.net/windowsCoverage.json"
).then((res) => res.json());
if (!data) {
throw new Error("Invalid response");
}
setCoverage(data.statementCoverage);
} catch (error) {
setErrorState(error);
}
};
fetchData();
}, []);

if (errorState) {
return (
<img
src={`https://img.shields.io/badge/Error-fetching-red`}
alt="Test Coverage Badge"
/>
);
}
console.log
return (
<div>
{coverage && (
<img
src={`https://img.shields.io/badge/${OS}-${coverage}-darkgreen`}
alt="Test Coverage Badge"
/>
)}
</div>
);
};

export default GetCoverageJSON;
12 changes: 12 additions & 0 deletions docs/TestCoverage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Test Coverage Report
Latest test coverage reports across OS.
It shows the percentage of code covered by various types of tests, including unit tests, component tests, and accessibility tests across chart types.
Go through it to analyze if your code is validated through test automations.

import GetCoverageJSON from "../apps/docsite/src/components/GetCoverageJSON.tsx"

| OS | Link | Status |
|----|------|--------|
| Code coverage for Windows | https://proud-island-067885010.4.azurestaticapps.net/windows-latest/index.html | <GetCoverageJSON OS="Windows"/> |
| Code coverage for Ubuntu | https://proud-island-067885010.4.azurestaticapps.net/ubuntu-latest/index.html | <GetCoverageJSON OS="Ubuntu"/> |
| Code coverage for MacOS | https://proud-island-067885010.4.azurestaticapps.net/macos-latest/index.html | <GetCoverageJSON OS="MacOS"/> |

0 comments on commit 6a2e25a

Please sign in to comment.