@analogjs/vitest-angular 3.0.0-alpha.88 → 3.0.0-alpha.89
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:
|
|
@@ -289,19 +297,7 @@ export default defineConfig(({ mode }) => ({
|
|
|
289
297
|
|
|
290
298
|
### With Nx
|
|
291
299
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
```ts
|
|
295
|
-
/// <reference types="vitest" />
|
|
296
|
-
import { defineConfig } from 'vite';
|
|
297
|
-
|
|
298
|
-
import angular from '@analogjs/vite-plugin-angular';
|
|
299
|
-
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
|
300
|
-
|
|
301
|
-
export default defineConfig(({ mode }) => ({
|
|
302
|
-
plugins: [angular(), nxViteTsPaths()],
|
|
303
|
-
}));
|
|
304
|
-
```
|
|
300
|
+
Nx workspaces use the same `vite-tsconfig-paths` plugin. The `nxViteTsPaths` plugin from `@nx/vite` is deprecated and is removed in Nx 24, so replace it with `viteTsConfigPaths()`.
|
|
305
301
|
|
|
306
302
|
## IDE Support
|
|
307
303
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@analogjs/vitest-angular",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.89",
|
|
4
4
|
"description": "Vitest Builder for Angular",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Brandon Roberts <robertsbt@gmail.com>",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@analogjs/vite-plugin-angular": "*",
|
|
59
59
|
"@angular-devkit/architect": ">=0.1500.0 < 0.2300.0",
|
|
60
60
|
"@angular-devkit/schematics": ">=17.0.0",
|
|
61
|
-
"vitest": "^1.3.1 || ^2.0.0 || ^3.0.0 || ^4.0.0",
|
|
61
|
+
"vitest": "^1.3.1 || ^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0",
|
|
62
62
|
"zone.js": ">=0.14.0"
|
|
63
63
|
},
|
|
64
64
|
"peerDependenciesMeta": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const ANALOG_JS_VITE_PLUGIN_ANGULAR = "^3.0.0-alpha.
|
|
1
|
+
export declare const ANALOG_JS_VITE_PLUGIN_ANGULAR = "^3.0.0-alpha.89";
|
|
2
2
|
export declare const JSDOM = "^22.0.0";
|
|
3
3
|
export declare const VITE_TSCONFIG_PATHS = "^4.2.0";
|
|
4
4
|
export declare const VITE = "^7.0.0";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region packages/vitest-angular-tools/src/schematics/utils/versions.ts
|
|
2
|
-
var ANALOG_JS_VITE_PLUGIN_ANGULAR = "^3.0.0-alpha.
|
|
2
|
+
var ANALOG_JS_VITE_PLUGIN_ANGULAR = "^3.0.0-alpha.89";
|
|
3
3
|
var JSDOM = "^22.0.0";
|
|
4
4
|
var VITE_TSCONFIG_PATHS = "^4.2.0";
|
|
5
5
|
var VITE = "^7.0.0";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versions.js","names":[],"sources":["../../../../../../../vitest-angular-tools/src/schematics/utils/versions.ts"],"sourcesContent":["// Version constants (Angular 20+)\nexport const ANALOG_JS_VITE_PLUGIN_ANGULAR = '^3.0.0-alpha.
|
|
1
|
+
{"version":3,"file":"versions.js","names":[],"sources":["../../../../../../../vitest-angular-tools/src/schematics/utils/versions.ts"],"sourcesContent":["// Version constants (Angular 20+)\nexport const ANALOG_JS_VITE_PLUGIN_ANGULAR = '^3.0.0-alpha.89';\nexport const JSDOM = '^22.0.0';\nexport const VITE_TSCONFIG_PATHS = '^4.2.0';\nexport const VITE = '^7.0.0';\nexport const VITEST_V4 = '^4.0.0';\n\n// Browser mode dependencies\nexport const VITEST_BROWSER_PLAYWRIGHT = '^4.0.0';\nexport const PLAYWRIGHT = '^1.54.0';\n"],"mappings":";AACA,IAAa,gCAAgC;AAC7C,IAAa,QAAQ;AACrB,IAAa,sBAAsB;AACnC,IAAa,OAAO;AACpB,IAAa,YAAY;AAGzB,IAAa,4BAA4B;AACzC,IAAa,aAAa"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const ANALOG_JS_VITE_PLUGIN_ANGULAR = "^3.0.0-alpha.
|
|
1
|
+
export declare const ANALOG_JS_VITE_PLUGIN_ANGULAR = "^3.0.0-alpha.89";
|
|
2
2
|
export declare const JSDOM = "^22.0.0";
|
|
3
3
|
export declare const VITE_TSCONFIG_PATHS = "^4.2.0";
|
|
4
4
|
export declare const VITE = "^7.0.0";
|