-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extremely slow coverage with v8, and nestjs while using testing modules #5322
Labels
duplicate
This issue or pull request already exists
feat: coverage
Issues and PRs related to the coverage feature
Comments
This is indeed duplicate of #5252. By patching the fix from #5259 your reproduction works fast.
"pnpm": {
"patchedDependencies": {
"@vitest/coverage-v8@1.3.1": "patches/@vitest__coverage-v8@1.3.1.patch"
}
diff --git a/dist/provider.js b/dist/provider.js
index 408c1c8d7c5053bd9d2d053717ea6d86140b34e9..0a15cfc5c641f3ecf4f1320d88a71524c8a2bac7 100644
--- a/dist/provider.js
+++ b/dist/provider.js
@@ -170,7 +170,7 @@ function cleanUrl(url) {
const WRAPPER_LENGTH = 185;
const VITE_EXPORTS_LINE_PATTERN = /Object\.defineProperty\(__vite_ssr_exports__.*\n/g;
-const DECORATOR_METADATA_PATTERN = /_ts_metadata\("design:paramtypes"(\s|.)+?]\),/g;
+const DECORATOR_METADATA_PATTERN = /_ts_metadata\("design:paramtypes", \[[^\]]*?\]\),*/g;
const DEFAULT_PROJECT = Symbol.for("default-project");
const debug = createDebug("vitest:coverage");
let uniqueId = 0; $ time pnpm run test:cov --run
> backend@0.0.1 test:cov /workspaces/nest-js-slow-coverage
> vitest --coverage "--run"
The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.
RUN v1.3.1 /workspaces/nest-js-slow-coverage
Coverage enabled with v8
✓ src/tools/__test__/test.service.spec.ts (1)
✓ ToolsService (1)
✓ createTool (1)
✓ should create a new tool
Test Files 1 passed (1)
Tests 1 passed (1)
Start at 07:37:35
Duration 898ms (transform 114ms, setup 0ms, collect 513ms, tests 12ms, environment 0ms, prepare 132ms)
% Coverage report from v8
-------------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-------------------|---------|----------|---------|---------|-------------------
All files | 46.83 | 25 | 16.66 | 46.83 |
src | 0 | 0 | 0 | 0 |
app.module.ts | 0 | 0 | 0 | 0 | 1-15
main.ts | 0 | 0 | 0 | 0 | 1-15
src/schemas | 100 | 100 | 100 | 100 |
tool.schema.ts | 100 | 100 | 100 | 100 |
src/tools | 80 | 100 | 33.33 | 80 |
tools.service.ts | 80 | 100 | 33.33 | 80 | 14-15,18-19
src/tools/mock | 0 | 0 | 0 | 0 |
MockToolModel.ts | 0 | 0 | 0 | 0 | 1-8
-------------------|---------|----------|---------|---------|-------------------
real 0m2.411s
user 0m2.099s
sys 0m1.313s |
AriPerkkio
added
duplicate
This issue or pull request already exists
feat: coverage
Issues and PRs related to the coverage feature
and removed
pending triage
labels
Mar 2, 2024
Oops sorry for the duplicate and thank you for the answer 😄 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
duplicate
This issue or pull request already exists
feat: coverage
Issues and PRs related to the coverage feature
Describe the bug
When running coverage on a nestjs project which uses
@nestjs/testing
, the report is very slow to report.On my machine (Macbook pro M2), it takes around 1m for one test with one mock.
It looks like #5252, but the PR still doesn't fix the issue on my machine (if I linked the project correctly on my machine).
Maybe there is something I don't understand with nestjs that makes coverages extremely slow?
Reproduction
pnpm vitest run --coverage
System Info
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: