Merge pull request #4500 from mermaid-js/sidv/mergeCoverage

Merge coverage
This commit is contained in:
Sidharth Vinod
2023-06-17 17:22:49 +05:30
committed by GitHub
5 changed files with 257 additions and 666 deletions

View File

@@ -124,7 +124,7 @@ export const getBuildConfig = ({ minify, core, watch, entryName }: BuildOptions)
// @ts-expect-error According to the type definitions, rollup plugins are incompatible with vite
typescript({ compilerOptions: { declaration: false } }),
istanbul({
exclude: ['node_modules', 'test/'],
exclude: ['node_modules', 'test/', '__mocks__'],
extension: ['.js', '.ts'],
requireEnv: true,
forceBuildInstrument: coverage,

View File

@@ -22,7 +22,6 @@
"build:watch": "pnpm build:vite --watch",
"build": "pnpm run -r clean && pnpm build:types && pnpm build:vite",
"dev": "concurrently \"pnpm build:vite --watch\" \"ts-node-esm .vite/server.ts\"",
"dev:coverage": "VITE_COVERAGE=true pnpm dev",
"release": "pnpm build",
"lint": "eslint --cache --cache-strategy content --ignore-path .gitignore . && pnpm lint:jison && prettier --cache --check .",
"lint:fix": "eslint --cache --cache-strategy content --fix --ignore-path .gitignore . && prettier --write . && ts-node-esm scripts/fixCSpell.ts",
@@ -32,6 +31,8 @@
"cypress:open": "cypress open",
"e2e": "start-server-and-test dev http://localhost:9000/ cypress",
"e2e:coverage": "VITE_COVERAGE=true pnpm e2e",
"coverage:merge": "ts-node-esm scripts/coverage.ts",
"coverage": "pnpm test:coverage && pnpm e2e:coverage && pnpm coverage:merge",
"ci": "vitest run",
"test": "pnpm lint && vitest run",
"test:watch": "vitest --watch",
@@ -57,7 +58,7 @@
]
},
"devDependencies": {
"@applitools/eyes-cypress": "^3.32.0",
"@applitools/eyes-cypress": "^3.33.1",
"@commitlint/cli": "^17.6.1",
"@commitlint/config-conventional": "^17.6.1",
"@cspell/eslint-plugin": "^6.31.1",
@@ -75,9 +76,9 @@
"@types/rollup-plugin-visualizer": "^4.2.1",
"@typescript-eslint/eslint-plugin": "^5.59.0",
"@typescript-eslint/parser": "^5.59.0",
"@vitest/coverage-c8": "^0.32.0",
"@vitest/spy": "^0.32.0",
"@vitest/ui": "^0.32.0",
"@vitest/coverage-istanbul": "^0.32.2",
"@vitest/spy": "^0.32.2",
"@vitest/ui": "^0.32.2",
"concurrently": "^8.0.1",
"cors": "^2.8.5",
"coveralls": "^3.1.1",
@@ -104,6 +105,7 @@
"js-yaml": "^4.1.0",
"jsdom": "^21.1.1",
"lint-staged": "^13.2.1",
"nyc": "^15.1.0",
"path-browserify": "^1.0.1",
"pnpm": "^8.3.1",
"prettier": "^2.8.8",
@@ -115,7 +117,7 @@
"typescript": "^5.1.3",
"vite": "^4.3.9",
"vite-plugin-istanbul": "^4.1.0",
"vitest": "^0.31.0"
"vitest": "^0.32.2"
},
"volta": {
"node": "18.16.0"

886
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

19
scripts/coverage.ts Normal file
View File

@@ -0,0 +1,19 @@
import { execSync } from 'child_process';
import { cp } from 'fs/promises';
const main = async () => {
const coverageDir = 'coverage';
const coverageFiles = ['vitest', 'cypress'].map(
(dir) => `${coverageDir}/${dir}/coverage-final.json`
);
//copy coverage files from vitest and cypress to coverage folder
await Promise.all(
coverageFiles.map((file) => cp(file, `${coverageDir}/combined/${file.split('/')[1]}.json`))
);
execSync('npx nyc merge coverage/combined coverage/combined-final.json');
execSync('npx nyc report -t coverage --report-dir coverage/html --reporter=html-spa');
};
void main();

View File

@@ -17,8 +17,10 @@ export default defineConfig({
// TODO: should we move this to a mermaid-core package?
setupFiles: ['packages/mermaid/src/tests/setup.ts'],
coverage: {
provider: 'istanbul',
reporter: ['text', 'json', 'html', 'lcov'],
reportsDirectory: './coverage/vitest',
exclude: ['**/node_modules/**', '**/tests/**', '**/__mocks__/**'],
},
},
build: {