diff --git a/package.json b/package.json index ce2bd569d..5447916f4 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ "test:coverage": "vitest --coverage", "prepublishOnly": "pnpm build && pnpm test", "prepare": "husky install && pnpm build", - "pre-commit": "lint-staged" + "pre-commit": "lint-staged", + "merge": "ts-node-esm scripts/coverage.ts" }, "repository": { "type": "git", @@ -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" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fac72d9f8..08f36596a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -62,15 +62,15 @@ importers: '@typescript-eslint/parser': specifier: ^5.59.0 version: 5.59.0(eslint@8.39.0)(typescript@5.1.3) - '@vitest/coverage-c8': - specifier: ^0.32.0 - version: 0.32.0(vitest@0.31.0) + '@vitest/coverage-istanbul': + specifier: ^0.32.2 + version: 0.32.2(vitest@0.32.2) '@vitest/spy': - specifier: ^0.32.0 - version: 0.32.0 + specifier: ^0.32.2 + version: 0.32.2 '@vitest/ui': - specifier: ^0.32.0 - version: 0.32.0(vitest@0.31.0) + specifier: ^0.32.2 + version: 0.32.2(vitest@0.32.2) concurrently: specifier: ^8.0.1 version: 8.0.1 @@ -149,6 +149,9 @@ importers: lint-staged: specifier: ^13.2.1 version: 13.2.1 + nyc: + specifier: ^15.1.0 + version: 15.1.0 path-browserify: specifier: ^1.0.1 version: 1.0.1 @@ -183,8 +186,8 @@ importers: specifier: ^4.1.0 version: 4.1.0(vite@4.3.9) vitest: - specifier: ^0.31.0 - version: 0.31.0(@vitest/ui@0.32.0)(jsdom@21.1.1) + specifier: ^0.32.2 + version: 0.32.2(@vitest/ui@0.32.2)(jsdom@21.1.1) packages/mermaid: dependencies: @@ -3549,7 +3552,7 @@ packages: glob: 7.2.3 graceful-fs: 4.2.10 istanbul-lib-coverage: 3.2.0 - istanbul-lib-instrument: 5.2.0 + istanbul-lib-instrument: 5.2.1 istanbul-lib-report: 3.0.0 istanbul-lib-source-maps: 4.0.1 istanbul-reports: 3.1.5 @@ -3953,11 +3956,11 @@ packages: /@types/chai-subset@1.3.3: resolution: {integrity: sha512-frBecisrNGz+F4T6bcc+NLeolfiojh5FxW2klu669+8BARtyQv2C/GkNW6FUodVe4BroGMP/wER/YDGc7rEllw==} dependencies: - '@types/chai': 4.3.4 + '@types/chai': 4.3.5 dev: true - /@types/chai@4.3.4: - resolution: {integrity: sha512-KnRanxnpfpjUTqTCXslZSEdLfXExwgNxYPdiO2WGUj8+HDjFi8R3k5RVKPeSCzLjCcshCAtVO2QBbVuAV4kTnw==} + /@types/chai@4.3.5: + resolution: {integrity: sha512-mEo1sAde+UCE6b2hxn332f1g1E8WfYRu6p5SvTKr2ZKC1f7gFJXk4h5PyGP9Dt6gCaG8y8XhwnXWC6Iy2cmBng==} dev: true /@types/connect-history-api-fallback@1.3.5: @@ -4662,7 +4665,7 @@ packages: debug: 4.3.4(supports-color@8.1.1) globby: 11.1.0 is-glob: 4.0.3 - semver: 7.3.8 + semver: 7.5.0 tsutils: 3.21.0(typescript@5.0.4) typescript: 5.0.4 transitivePeerDependencies: @@ -4683,7 +4686,7 @@ packages: debug: 4.3.4(supports-color@8.1.1) globby: 11.1.0 is-glob: 4.0.3 - semver: 7.3.8 + semver: 7.5.0 tsutils: 3.21.0(typescript@5.1.3) typescript: 5.1.3 transitivePeerDependencies: @@ -4704,7 +4707,7 @@ packages: '@typescript-eslint/typescript-estree': 5.59.0(typescript@5.0.4) eslint: 8.39.0 eslint-scope: 5.1.1 - semver: 7.3.8 + semver: 7.5.0 transitivePeerDependencies: - supports-color - typescript @@ -4724,7 +4727,7 @@ packages: '@typescript-eslint/typescript-estree': 5.59.0(typescript@5.1.3) eslint: 8.39.0 eslint-scope: 5.1.1 - semver: 7.3.8 + semver: 7.5.0 transitivePeerDependencies: - supports-color - typescript @@ -4968,83 +4971,72 @@ packages: vue: 3.3.4 dev: true - /@vitest/coverage-c8@0.32.0(vitest@0.31.0): - resolution: {integrity: sha512-FeTzRN5VCL7B6YTRK5ZPQO2iwJzl2x7/mTQ/2uEeKZatAYBtvczeAYnzSUhCPev7p99+5skxMQZwqVcFTrVCdg==} + /@vitest/coverage-istanbul@0.32.2(vitest@0.32.2): + resolution: {integrity: sha512-B5VSvfzwTsDt9HjFmQ4sZ2tQHivmHJpAoG/BJwNNQeBtSCSdY1L6tfCjwZLo7ryOmZEDA3ck/DAmHCUZqa+MWA==} peerDependencies: - vitest: '>=0.30.0 <1' + vitest: '>=0.32.0 <1' dependencies: - '@ampproject/remapping': 2.2.1 - c8: 7.13.0 - magic-string: 0.30.0 - picocolors: 1.0.0 - std-env: 3.3.2 - vitest: 0.31.0(@vitest/ui@0.32.0)(jsdom@21.1.1) + istanbul-lib-coverage: 3.2.0 + istanbul-lib-instrument: 5.2.1 + istanbul-lib-report: 3.0.0 + istanbul-lib-source-maps: 4.0.1 + istanbul-reports: 3.1.5 + test-exclude: 6.0.0 + vitest: 0.32.2(@vitest/ui@0.32.2)(jsdom@21.1.1) + transitivePeerDependencies: + - supports-color dev: true - /@vitest/expect@0.31.0: - resolution: {integrity: sha512-Jlm8ZTyp6vMY9iz9Ny9a0BHnCG4fqBa8neCF6Pk/c/6vkUk49Ls6UBlgGAU82QnzzoaUs9E/mUhq/eq9uMOv/g==} + /@vitest/expect@0.32.2: + resolution: {integrity: sha512-6q5yzweLnyEv5Zz1fqK5u5E83LU+gOMVBDuxBl2d2Jfx1BAp5M+rZgc5mlyqdnxquyoiOXpXmFNkcGcfFnFH3Q==} dependencies: - '@vitest/spy': 0.31.0 - '@vitest/utils': 0.31.0 + '@vitest/spy': 0.32.2 + '@vitest/utils': 0.32.2 chai: 4.3.7 dev: true - /@vitest/runner@0.31.0: - resolution: {integrity: sha512-H1OE+Ly7JFeBwnpHTrKyCNm/oZgr+16N4qIlzzqSG/YRQDATBYmJb/KUn3GrZaiQQyL7GwpNHVZxSQd6juLCgw==} + /@vitest/runner@0.32.2: + resolution: {integrity: sha512-06vEL0C1pomOEktGoLjzZw+1Fb+7RBRhmw/06WkDrd1akkT9i12su0ku+R/0QM69dfkIL/rAIDTG+CSuQVDcKw==} dependencies: - '@vitest/utils': 0.31.0 + '@vitest/utils': 0.32.2 concordance: 5.0.4 p-limit: 4.0.0 pathe: 1.1.0 dev: true - /@vitest/snapshot@0.31.0: - resolution: {integrity: sha512-5dTXhbHnyUMTMOujZPB0wjFjQ6q5x9c8TvAsSPUNKjp1tVU7i9pbqcKPqntyu2oXtmVxKbuHCqrOd+Ft60r4tg==} + /@vitest/snapshot@0.32.2: + resolution: {integrity: sha512-JwhpeH/PPc7GJX38vEfCy9LtRzf9F4er7i4OsAJyV7sjPwjj+AIR8cUgpMTWK4S3TiamzopcTyLsZDMuldoi5A==} dependencies: magic-string: 0.30.0 pathe: 1.1.0 pretty-format: 27.5.1 dev: true - /@vitest/spy@0.31.0: - resolution: {integrity: sha512-IzCEQ85RN26GqjQNkYahgVLLkULOxOm5H/t364LG0JYb3Apg0PsYCHLBYGA006+SVRMWhQvHlBBCyuByAMFmkg==} + /@vitest/spy@0.32.2: + resolution: {integrity: sha512-Q/ZNILJ4ca/VzQbRM8ur3Si5Sardsh1HofatG9wsJY1RfEaw0XKP8IVax2lI1qnrk9YPuG9LA2LkZ0EI/3d4ug==} dependencies: tinyspy: 2.1.0 dev: true - /@vitest/spy@0.32.0: - resolution: {integrity: sha512-MruAPlM0uyiq3d53BkwTeShXY0rYEfhNGQzVO5GHBmmX3clsxcWp79mMnkOVcV244sNTeDcHbcPFWIjOI4tZvw==} - dependencies: - tinyspy: 2.1.0 - dev: true - - /@vitest/ui@0.32.0(vitest@0.31.0): - resolution: {integrity: sha512-55gugh6+owrOqW83RCgLm9q+o3SlzvFVgl1lyfnr0WB8ABxLoM+3pgusEjosscgEYGzTjTXaZY6xLd4qlfH/RQ==} + /@vitest/ui@0.32.2(vitest@0.32.2): + resolution: {integrity: sha512-N5JKftnB8qzKFtpQC5OcUGxYTLo6wiB/95Lgyk6MF52t74Y7BJOWbf6EFYhXqt9J0MSbhOR2kapq+WKKUGDW0g==} peerDependencies: vitest: '>=0.30.1 <1' dependencies: - '@vitest/utils': 0.32.0 + '@vitest/utils': 0.32.2 fast-glob: 3.2.12 fflate: 0.7.4 flatted: 3.2.7 pathe: 1.1.0 picocolors: 1.0.0 sirv: 2.0.3 - vitest: 0.31.0(@vitest/ui@0.32.0)(jsdom@21.1.1) + vitest: 0.32.2(@vitest/ui@0.32.2)(jsdom@21.1.1) dev: true - /@vitest/utils@0.31.0: - resolution: {integrity: sha512-kahaRyLX7GS1urekRXN2752X4gIgOGVX4Wo8eDUGUkTWlGpXzf5ZS6N9RUUS+Re3XEE8nVGqNyxkSxF5HXlGhQ==} + /@vitest/utils@0.32.2: + resolution: {integrity: sha512-lnJ0T5i03j0IJaeW73hxe2AuVnZ/y1BhhCOuIcl9LIzXnbpXJT9Lrt6brwKHXLOiA7MZ6N5hSJjt0xE1dGNCzQ==} dependencies: - concordance: 5.0.4 - loupe: 2.3.6 - pretty-format: 27.5.1 - dev: true - - /@vitest/utils@0.32.0: - resolution: {integrity: sha512-53yXunzx47MmbuvcOPpLaVljHaeSu1G2dHdmy7+9ngMnQIkBQcvwOcoclWFnxDMxFbnq8exAfh3aKSZaK71J5A==} - dependencies: - concordance: 5.0.4 + diff-sequences: 29.4.3 loupe: 2.3.6 pretty-format: 27.5.1 dev: true @@ -6005,7 +5997,7 @@ packages: '@babel/helper-plugin-utils': 7.20.2 '@istanbuljs/load-nyc-config': 1.1.0 '@istanbuljs/schema': 0.1.3 - istanbul-lib-instrument: 5.2.0 + istanbul-lib-instrument: 5.2.1 test-exclude: 6.0.0 transitivePeerDependencies: - supports-color @@ -6282,25 +6274,6 @@ packages: engines: {node: '>= 0.8'} dev: true - /c8@7.13.0: - resolution: {integrity: sha512-/NL4hQTv1gBL6J6ei80zu3IiTrmePDKXKXOTLpHvcIWZTVYQlDhVWjjWvkhICylE8EwwnMVzDZugCvdx0/DIIA==} - engines: {node: '>=10.12.0'} - hasBin: true - dependencies: - '@bcoe/v8-coverage': 0.2.3 - '@istanbuljs/schema': 0.1.3 - find-up: 5.0.0 - foreground-child: 2.0.0 - istanbul-lib-coverage: 3.2.0 - istanbul-lib-report: 3.0.0 - istanbul-reports: 3.1.5 - rimraf: 3.0.2 - test-exclude: 6.0.0 - v8-to-istanbul: 9.0.1 - yargs: 16.2.0 - yargs-parser: 20.2.9 - dev: true - /cac@6.7.14: resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} engines: {node: '>=8'} @@ -6604,14 +6577,6 @@ packages: wrap-ansi: 6.2.0 dev: true - /cliui@7.0.4: - resolution: {integrity: sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==} - dependencies: - string-width: 4.2.3 - strip-ansi: 6.0.1 - wrap-ansi: 7.0.0 - dev: true - /cliui@8.0.1: resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} engines: {node: '>=12'} @@ -10091,6 +10056,19 @@ packages: - supports-color dev: true + /istanbul-lib-instrument@5.2.1: + resolution: {integrity: sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==} + engines: {node: '>=8'} + dependencies: + '@babel/core': 7.12.3 + '@babel/parser': 7.21.8 + '@istanbuljs/schema': 0.1.3 + istanbul-lib-coverage: 3.2.0 + semver: 6.3.0 + transitivePeerDependencies: + - supports-color + dev: true + /istanbul-lib-processinfo@2.0.3: resolution: {integrity: sha512-NkwHbo3E00oybX6NGJi6ar0B29vxyvNwoC7eJ4G4Yq28UfY758Hgn/heV8VRFhevPED4LXfFz0DQ8z/0kw9zMg==} engines: {node: '>=8'} @@ -14328,8 +14306,8 @@ packages: engines: {node: '>=6'} dev: true - /tinybench@2.4.0: - resolution: {integrity: sha512-iyziEiyFxX4kyxSp+MtY1oCH/lvjH3PxFN8PGCDeqcZWAJ/i+9y+nL85w99PxVzrIvew/GSkSbDYtiGVa85Afg==} + /tinybench@2.5.0: + resolution: {integrity: sha512-kRwSG8Zx4tjF9ZiyH4bhaebu+EDz1BOx9hOigYHlUW4xxI/wKIUQUqo018UlU4ar6ATPBsaMrdbKZ+tmPdohFA==} dev: true /tinypool@0.5.0: @@ -14976,8 +14954,8 @@ packages: vfile-message: 3.1.2 dev: true - /vite-node@0.31.0(@types/node@18.16.0): - resolution: {integrity: sha512-8x1x1LNuPvE2vIvkSB7c1mApX5oqlgsxzHQesYF7l5n1gKrEmrClIiZuOFbFDQcjLsmcWSwwmrWrcGWm9Fxc/g==} + /vite-node@0.32.2(@types/node@18.16.0): + resolution: {integrity: sha512-dTQ1DCLwl2aEseov7cfQ+kDMNJpM1ebpyMMMwWzBvLbis8Nla/6c9WQcqpPssTwS6Rp/+U6KwlIj8Eapw4bLdA==} engines: {node: '>=v14.18.0'} hasBin: true dependencies: @@ -15258,8 +15236,8 @@ packages: - universal-cookie dev: true - /vitest@0.31.0(@vitest/ui@0.32.0)(jsdom@21.1.1): - resolution: {integrity: sha512-JwWJS9p3GU9GxkG7eBSmr4Q4x4bvVBSswaCFf1PBNHiPx00obfhHRJfgHcnI0ffn+NMlIh9QGvG75FlaIBdKGA==} + /vitest@0.32.2(@vitest/ui@0.32.2)(jsdom@21.1.1): + resolution: {integrity: sha512-hU8GNNuQfwuQmqTLfiKcqEhZY72Zxb7nnN07koCUNmntNxbKQnVbeIS6sqUgR3eXSlbOpit8+/gr1KpqoMgWCQ==} engines: {node: '>=v14.18.0'} hasBin: true peerDependencies: @@ -15289,15 +15267,15 @@ packages: webdriverio: optional: true dependencies: - '@types/chai': 4.3.4 + '@types/chai': 4.3.5 '@types/chai-subset': 1.3.3 '@types/node': 18.16.0 - '@vitest/expect': 0.31.0 - '@vitest/runner': 0.31.0 - '@vitest/snapshot': 0.31.0 - '@vitest/spy': 0.31.0 - '@vitest/ui': 0.32.0(vitest@0.31.0) - '@vitest/utils': 0.31.0 + '@vitest/expect': 0.32.2 + '@vitest/runner': 0.32.2 + '@vitest/snapshot': 0.32.2 + '@vitest/spy': 0.32.2 + '@vitest/ui': 0.32.2(vitest@0.32.2) + '@vitest/utils': 0.32.2 acorn: 8.8.2 acorn-walk: 8.2.0 cac: 6.7.14 @@ -15311,10 +15289,10 @@ packages: picocolors: 1.0.0 std-env: 3.3.2 strip-literal: 1.0.1 - tinybench: 2.4.0 + tinybench: 2.5.0 tinypool: 0.5.0 vite: 4.3.9(@types/node@18.16.0) - vite-node: 0.31.0(@types/node@18.16.0) + vite-node: 0.32.2(@types/node@18.16.0) why-is-node-running: 2.2.2 transitivePeerDependencies: - less @@ -16134,19 +16112,6 @@ packages: yargs-parser: 18.1.3 dev: true - /yargs@16.2.0: - resolution: {integrity: sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==} - engines: {node: '>=10'} - dependencies: - cliui: 7.0.4 - escalade: 3.1.1 - get-caller-file: 2.0.5 - require-directory: 2.1.1 - string-width: 4.2.3 - y18n: 5.0.8 - yargs-parser: 20.2.9 - dev: true - /yargs@17.6.2: resolution: {integrity: sha512-1/9UrdHjDZc0eOU0HxOHoS78C69UD3JRMvzlJ7S79S2nTaWRA/whGCTV8o9e/N/1Va9YIV7Q4sOxD8VV4pCWOw==} engines: {node: '>=12'} diff --git a/scripts/coverage.ts b/scripts/coverage.ts new file mode 100644 index 000000000..8cc8961da --- /dev/null +++ b/scripts/coverage.ts @@ -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(); diff --git a/vite.config.ts b/vite.config.ts index 582671f11..5b658f4b8 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -17,6 +17,7 @@ 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', },