You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f89750b
Browse filesBrowse the repository at this point in the historyBrowse files
fix(@schematics/angular): add addImports option to jasmine-vitest schematic
Introduces a new `--add-imports` boolean option to the Jasmine to Vitest refactoring schematic.
When this option is set to `true`, the schematic will automatically add a single, consolidated `import { ... } from 'vitest';` statement at the top of the transformed file for any Vitest APIs that are used.
Key changes:
- Type-only imports (e.g., `Mock`, `MockedObject`) are now always added to ensure the refactored code remains type-correct.
- Value imports (e.g., `vi`, `describe`, `it`, `expect`) are only added when `--add-imports` is `true`.
- The import generation logic correctly handles all scenarios, including type-only imports (`import type {...}`), value-only imports, and combined imports with inline `type` keywords.
- A new test suite has been added to validate the import generation logic under various conditions.
(cherry picked from commit cc132e9)
Copy file name to clipboardExpand all lines: packages/schematics/angular/refactor/jasmine-vitest/schema.json
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,11 @@
25
25
"type": "boolean",
26
26
"description": "Enable verbose logging to see detailed information about the transformations being applied.",
27
27
"default": false
28
+
},
29
+
"addImports": {
30
+
"type": "boolean",
31
+
"description": "Whether to add imports for the Vitest API. The Angular `unit-test` system automatically uses the Vitest globals option, which means explicit imports for global APIs like `describe`, `it`, `expect`, and `vi` are often not strictly necessary unless Vitest has been configured not to use globals.",
0 commit comments