forked from JeremyHeleine/Photo-Sphere-Viewer
-
-
Notifications
You must be signed in to change notification settings - Fork 686
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
59 changed files
with
975 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
node_modules | ||
yarn-error.log | ||
.nyc_output | ||
.tmp | ||
.turbo | ||
docs/.vitepress/cache | ||
docs/.vitepress/.temp | ||
.typedoc | ||
!docs/.typedoc | ||
dist | ||
/public | ||
reports | ||
cypress/screenshots | ||
cypress/snapshots/diff | ||
.tmp | ||
dist | ||
docs/.vitepress/.temp | ||
docs/.vitepress/cache | ||
node_modules | ||
public | ||
reports | ||
yarn-error.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"report-dir": "./cypress/reports", | ||
"reporter": ["@lcov-viewer/istanbul-report"], | ||
"exclude": ["icons/**"], | ||
"excludeAfterRemap": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* Generates a markdown summary from the coverage report | ||
*/ | ||
|
||
import vm from 'node:vm'; | ||
import { readFileSync } from 'node:fs'; | ||
|
||
const TOTAL = '_total_'; | ||
|
||
const script = new vm.Script(readFileSync('cypress/reports/lcov-viewer/report-data.js')); | ||
const context = vm.createContext({ window: {} }); | ||
script.runInContext(context); | ||
|
||
const values = Object.values(context.window.COVERAGE_DATA) | ||
.reduce((result, { metrics, path }) => { | ||
const module = path.split('/').shift(); | ||
[TOTAL, module].forEach(key => { | ||
const moduleMetrics = result[key] ?? { | ||
branches: { total: 0, covered: 0 }, | ||
functions: { total: 0, covered: 0 }, | ||
lines: { total: 0, covered: 0 }, | ||
}; | ||
|
||
moduleMetrics.branches.total += metrics.branches.total; | ||
moduleMetrics.branches.covered += metrics.branches.covered; | ||
moduleMetrics.functions.total += metrics.functions.total; | ||
moduleMetrics.functions.covered += metrics.functions.covered; | ||
moduleMetrics.lines.total += metrics.lines.total; | ||
moduleMetrics.lines.covered += metrics.lines.covered; | ||
|
||
result[key] = moduleMetrics; | ||
}); | ||
return result; | ||
}, {}); | ||
|
||
function percentWithColor({ covered, total }) { | ||
const percent = Math.round(covered / total * 10000) / 100; | ||
const color = percent >= 80 ? '#248f29' : percent >= 60 ? '#d3b334' : '#d3343c'; | ||
return `\${\\textsf{\\color{${color}}${percent.toFixed(1)}\\\\%}}$`; | ||
} | ||
|
||
const summary = ` | ||
# ${percentWithColor(values[TOTAL].lines)} lines, ${percentWithColor(values[TOTAL].functions)} functions, ${percentWithColor(values[TOTAL].branches)} branches | ||
| Package | Lines | Line Coverage | Functions | Function Coverage | Branches | Branch Coverage | | ||
| ------- | -----:| ------------- | ---------:| ----------------- | --------:| ----------------| | ||
${Object.entries(values) | ||
.filter(([name]) => name !== TOTAL) | ||
.map(([name, { lines, functions, branches }]) => { | ||
const entry = ({ covered, total }) => `${covered}/${total} | ${percentWithColor({ covered, total })}`; | ||
return `| **${name}** | ${entry(lines)} | ${entry(functions)} | ${entry(branches)} |`; | ||
}) | ||
.join('\n') | ||
} | ||
`; | ||
|
||
console.log(summary); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.