forked from stakwork/sphinx-nav-fiber
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add checking the coverage report (stakwork#350)
* test: add checking the coverage report * fix: add timeout * test: add an action for coverage report * fix: add a name to the task * test: add version of the action to actions * fix: fix action * test: test coverage script * fix: test actions * fix: change action run for instrument the code for code coverage * fix: update gitignore * fix: reinstall deps * fix: eslint --------- Co-authored-by: Github Actions <[email protected]>
- Loading branch information
Showing
13 changed files
with
919 additions
and
412 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 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 |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
/coverage | ||
/cypress/videos | ||
/cypress/screenshots | ||
/.nyc_output | ||
|
||
# production | ||
build/ | ||
|
288 changes: 144 additions & 144 deletions
288
build/assets/index-9e3ca490.js → build/assets/index-c9cf93ba.js
Large diffs are not rendered by default.
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
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,63 @@ | ||
/* eslint-disable no-throw-literal */ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
/* eslint-disable no-console */ | ||
const { exec } = require('child_process') | ||
const { readFileSync } = require('fs') | ||
const path = require('path') | ||
|
||
const getPackageJSON = () => { | ||
const packageJSONPath = path.join(__dirname, '../package.json') | ||
const packageJsonFile = readFileSync(packageJSONPath) | ||
const data = JSON.parse(packageJsonFile) | ||
|
||
return data | ||
} | ||
|
||
const getCoverageReportValue = () => | ||
new Promise((res, rej) => { | ||
exec('npx nyc report --reporter=text-summary', (err, stdout, stderr) => { | ||
if (err) { | ||
rej(stderr || err) | ||
} | ||
|
||
try { | ||
const summaryRegexp = /\d{2}.\d{1}/ | ||
const coverageReportValueString = stdout.match(summaryRegexp)?.[0] | ||
const coverageValueNumber = parseFloat(coverageReportValueString) | ||
|
||
if (!coverageValueNumber) { | ||
console.error('coverageValueNumber was parsed incorrectly') | ||
process.exit(1) | ||
} | ||
|
||
res(coverageValueNumber) | ||
} catch (e) { | ||
rej(e) | ||
} | ||
}) | ||
}) | ||
|
||
;(async () => { | ||
const data = getPackageJSON() | ||
const minCoverageValue = data.coverage.min | ||
|
||
console.log('🚀 required coverage', minCoverageValue) | ||
|
||
if (!minCoverageValue) { | ||
console.error('minCoverageValue from package.json was parsed incorrectly') | ||
process.exit(1) | ||
} | ||
|
||
const valueReportValue = await getCoverageReportValue() | ||
|
||
console.log('🚀 coverage report value', valueReportValue) | ||
|
||
if (valueReportValue < minCoverageValue) { | ||
console.error('Project test coverage less then required') | ||
process.exit(1) | ||
} | ||
|
||
console.log('Coverage is good') | ||
})() | ||
|
||
process.on('exit', (code) => console.error(`exiting the code ${code}`)) |
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
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 |
---|---|---|
|
@@ -74,6 +74,7 @@ | |
"build-preview-e2e": "VITE_APP_IS_E2E=true yarn run build && vite preview --port 3000", | ||
"test": "NODE_ENV=test yarn jest", | ||
"test-start": "yarn jest --watch", | ||
"test-coverage": "node ./cypress/coverageTest.js", | ||
"cy-open": "cypress open", | ||
"cy-run": "cypress run", | ||
"format": "prettier --write --config prettier.config.js ./src", | ||
|
@@ -131,6 +132,7 @@ | |
"@babel/preset-typescript": "^7.21.5", | ||
"@commitlint/cli": "^17.1.2", | ||
"@commitlint/config-conventional": "^17.1.0", | ||
"@cypress/code-coverage": "^3.11.0", | ||
"@esbuild-plugins/node-globals-polyfill": "^0.2.3", | ||
"@testing-library/jest-dom": "^5.16.5", | ||
"@testing-library/react": "^14.0.0", | ||
|
@@ -149,7 +151,7 @@ | |
"@typescript-eslint/parser": "^5.27.1", | ||
"@vitejs/plugin-react": "^4.0.0", | ||
"babel-plugin-transform-vite-meta-env": "^1.0.3", | ||
"cypress": "^12.2.0", | ||
"cypress": "12.16.0", | ||
"eslint": "^8.41.0", | ||
"eslint-config-airbnb": "^19.0.4", | ||
"eslint-config-prettier": "^8.5.0", | ||
|
@@ -173,12 +175,21 @@ | |
"vite": "^4.3.9", | ||
"vite-compatible-readable-stream": "^3.6.1", | ||
"vite-plugin-eslint": "^1.8.1", | ||
"vite-plugin-istanbul": "^4.1.0", | ||
"vite-plugin-node-polyfills": "^0.8.2", | ||
"vite-plugin-svgr": "^3.2.0", | ||
"vite-tsconfig-paths": "^4.2.0" | ||
}, | ||
"packageManager": "[email protected]", | ||
"engines": { | ||
"node": ">=16.0.0" | ||
}, | ||
"nyc": { | ||
"reporter": [ | ||
"html" | ||
] | ||
}, | ||
"coverage": { | ||
"min": 65 | ||
} | ||
} |
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.