@analogjs/vitest-angular 2.7.1-beta.3 → 2.7.1
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
|
@@ -99,9 +99,11 @@ As of Angular v21, `Zoneless` change detection is the default for new projects.
|
|
|
99
99
|
Use the following setup:
|
|
100
100
|
|
|
101
101
|
```ts
|
|
102
|
+
// src/test-setup.ts
|
|
102
103
|
import '@angular/compiler';
|
|
103
104
|
import '@analogjs/vitest-angular/setup-snapshots';
|
|
104
105
|
import '@analogjs/vitest-angular/setup-serializers';
|
|
106
|
+
|
|
105
107
|
import { setupTestBed } from '@analogjs/vitest-angular/setup-testbed';
|
|
106
108
|
|
|
107
109
|
setupTestBed();
|
|
@@ -109,11 +111,13 @@ setupTestBed();
|
|
|
109
111
|
|
|
110
112
|
### Zone.js setup
|
|
111
113
|
|
|
112
|
-
If you are using `Zone.js` for change detection, import the `setup-zone` script
|
|
114
|
+
If you are using `Zone.js` for change detection, import the `setup-zone` script before setting up the `TestBed`. This script patches the test environment for `Zone.js` helpers such as `fakeAsync`, and automatically includes support for setting up snapshot tests.
|
|
113
115
|
|
|
114
116
|
```ts
|
|
117
|
+
// src/test-setup.ts
|
|
115
118
|
import '@angular/compiler';
|
|
116
119
|
import '@analogjs/vitest-angular/setup-zone';
|
|
120
|
+
|
|
117
121
|
import { setupTestBed } from '@analogjs/vitest-angular/setup-testbed';
|
|
118
122
|
|
|
119
123
|
setupTestBed({
|
|
@@ -121,6 +125,10 @@ setupTestBed({
|
|
|
121
125
|
});
|
|
122
126
|
```
|
|
123
127
|
|
|
128
|
+
The side effect imports must come first. If your formatter sorts side effect imports below named imports, keep them in a separate import group with a blank line, or exclude `src/test-setup.ts` from import sorting.
|
|
129
|
+
|
|
130
|
+
> **Note:** With `Zone.js`, use Vitest's global test functions, with `globals: true` set in the `vite.config.mts`, and `vitest/globals` added to the `types` array in the `tsconfig.spec.json`. Importing `describe`, `it`, `beforeEach`, and other functions from `vitest` directly bypasses the `Zone.js` patching, and `fakeAsync` fails with the error `Expected to be running in 'ProxyZone', but it was not found`. Zoneless tests have no such restriction — when migrating to zoneless change detection, you can switch back to importing the functions from `vitest`.
|
|
131
|
+
|
|
124
132
|
### Configuration Options
|
|
125
133
|
|
|
126
134
|
The `setupTestBed()` function accepts an optional configuration object with the following properties:
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PLAYWRIGHT = exports.VITEST_BROWSER_PLAYWRIGHT = exports.VITEST_V4 = exports.VITE = exports.VITE_TSCONFIG_PATHS = exports.JSDOM = exports.ANALOG_JS_VITE_PLUGIN_ANGULAR = void 0;
|
|
4
4
|
// Version constants (Angular 20+)
|
|
5
|
-
exports.ANALOG_JS_VITE_PLUGIN_ANGULAR = '^2.7.1
|
|
5
|
+
exports.ANALOG_JS_VITE_PLUGIN_ANGULAR = '^2.7.1';
|
|
6
6
|
exports.JSDOM = '^22.0.0';
|
|
7
7
|
exports.VITE_TSCONFIG_PATHS = '^4.2.0';
|
|
8
8
|
exports.VITE = '^7.0.0';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versions.js","sourceRoot":"","sources":["../../../../../../../../../packages/vitest-angular-tools/src/schematics/utils/versions.ts"],"names":[],"mappings":";;;AAAA,kCAAkC;AACrB,QAAA,6BAA6B,GAAG,
|
|
1
|
+
{"version":3,"file":"versions.js","sourceRoot":"","sources":["../../../../../../../../../packages/vitest-angular-tools/src/schematics/utils/versions.ts"],"names":[],"mappings":";;;AAAA,kCAAkC;AACrB,QAAA,6BAA6B,GAAG,QAAQ,CAAC;AACzC,QAAA,KAAK,GAAG,SAAS,CAAC;AAClB,QAAA,mBAAmB,GAAG,QAAQ,CAAC;AAC/B,QAAA,IAAI,GAAG,QAAQ,CAAC;AAChB,QAAA,SAAS,GAAG,QAAQ,CAAC;AAElC,4BAA4B;AACf,QAAA,yBAAyB,GAAG,QAAQ,CAAC;AACrC,QAAA,UAAU,GAAG,SAAS,CAAC"}
|