@liively/swc-jest-coverage-nestjs-plugin 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -66,7 +66,53 @@ module.exports = {
66
66
 
67
67
  > **Note:** `stripMetadata` defaults to `false` because `@nestjs/mongoose` depends on `design:type` metadata at runtime for schema type inference. Only enable it if your project does not use Mongoose (or any other library that reads `design:type` metadata).
68
68
 
69
- > **Note:** `simplifyDesignTypeTypeofs` defaults to `false` because `@nestjs/mongoose` `@Prop()` uses `design:type` to infer schema types at runtime. Enable it only if your `design:type` metadata contains member-expression types (e.g. `mongoose.Types.ObjectId`) that generate phantom branch coverage from always-true typeof guards.
69
+ > **Note:** `simplifyDesignTypeTypeofs` defaults to `false` because `@nestjs/mongoose` `@Prop()` uses `design:type` to infer schema types at runtime. Enable it only if your `design:type` metadata contains member-expression types (e.g. `mongoose.Types.ObjectId`) that generate phantom branch coverage from always-true typeof guards. For mixed codebases, use [per-file overrides](#per-file-overrides) to enable this selectively.
70
+
71
+ ### Per-File Overrides
72
+
73
+ You can apply different options to different files using `overrides`, similar to ESLint's override syntax. Each override specifies glob patterns and config options to apply when a file matches:
74
+
75
+ ```js
76
+ // jest.config.js
77
+ module.exports = {
78
+ transform: {
79
+ '^.+\\.tsx?$': [
80
+ '@swc/jest',
81
+ {
82
+ jsc: {
83
+ experimental: {
84
+ plugins: [
85
+ ['@liively/swc-jest-coverage-nestjs-plugin', {
86
+ simplifyDesignTypeTypeofs: false,
87
+ overrides: [
88
+ {
89
+ files: [
90
+ '**/venue.model*',
91
+ '**/user.model*',
92
+ '**/role.model*',
93
+ ],
94
+ config: {
95
+ simplifyDesignTypeTypeofs: true,
96
+ },
97
+ },
98
+ ],
99
+ }],
100
+ ],
101
+ },
102
+ },
103
+ },
104
+ ],
105
+ },
106
+ };
107
+ ```
108
+
109
+ **Behavior:**
110
+
111
+ - Glob syntax supports `*`, `**`, `{a,b}`, and `?` patterns
112
+ - Later overrides take precedence when multiple rules match the same file
113
+ - Only specified fields in an override are applied; unspecified fields inherit from the base config
114
+ - If SWC doesn't provide a filename (unlikely in practice), overrides are skipped and the base config is used
115
+ - Windows backslash paths are normalized to forward slashes before matching
70
116
 
71
117
  ## How It Works
72
118
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liively/swc-jest-coverage-nestjs-plugin",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "SWC plugin to transform NestJS decorator metadata for accurate Jest coverage",
5
5
  "main": "swc_jest_coverage_nestjs_plugin.wasm",
6
6
  "files": [