vitest-browser-angular 0.2.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/dist/setup.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { t as setupAngularTestEnvironment } from "./setup-N1YCbpUn.mjs";
1
+ import { t as setupAngularTestEnvironment } from "./setup-DWV3P7kE.mjs";
2
2
 
3
3
  export { setupAngularTestEnvironment };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-browser-angular",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Render Angular components in VItest Browser Mode",
5
5
  "author": "Shai Reznik (HiRez.io)",
6
6
  "license": "MIT",
@@ -45,18 +45,18 @@
45
45
  "node": "^18.0.0 || ^20.0.0 || >=22.0.0"
46
46
  },
47
47
  "peerDependencies": {
48
- "@angular/core": "^20.0.0",
49
- "@angular/router": "^20.0.0",
48
+ "@angular/core": "^20.0.0 || ^21.0.0",
49
+ "@angular/router": "^20.0.0 || ^21.0.0",
50
50
  "@vitest/browser": "^2.1.0 || ^3.0.0 || ^4.0.0-0",
51
51
  "vitest": "^2.1.0 || ^3.0.0 || ^4.0.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@analogjs/vite-plugin-angular": "2.2.0",
55
55
  "@analogjs/vitest-angular": "2.2.0",
56
- "@angular/compiler": "^20.3.0",
57
- "@angular/core": "^20.3.0",
58
- "@angular/platform-browser": "^20.3.0",
59
- "@angular/router": "^20.3.0",
56
+ "@angular/compiler": "^21.0.0",
57
+ "@angular/core": "^21.0.0",
58
+ "@angular/platform-browser": "^21.0.0",
59
+ "@angular/router": "^21.0.0",
60
60
  "@changesets/cli": "^2.29.6",
61
61
  "@changesets/get-github-info": "^0.6.0",
62
62
  "@changesets/types": "^6.1.0",
@@ -73,14 +73,16 @@
73
73
  "playwright": "^1.46.0",
74
74
  "prettier": "^3.6.2",
75
75
  "pretty-quick": "^4.2.2",
76
+ "rxjs": "~7.8.2",
76
77
  "simple-git-hooks": "^2.13.1",
77
78
  "tsdown": "^0.16.2",
79
+ "tslib": "^2.8.1",
78
80
  "tsx": "^4.17.0",
79
- "typescript": "^5.5.4",
81
+ "typescript": "~5.9.2",
80
82
  "typescript-eslint": "^8.42.0",
81
83
  "vite": "^7.1.0",
82
- "vitest": "^4.0.0",
83
- "zone.js": "^0.15.1",
84
+ "vitest": "^4.0.8",
85
+ "zone.js": "~0.15.0",
84
86
  "zx": "^8.1.4"
85
87
  },
86
88
  "simple-git-hooks": {
@@ -1,42 +0,0 @@
1
- import { page } from "vitest/browser";
2
- import { inputBinding } from "@angular/core";
3
- import { TestBed, ɵgetCleanupHook } from "@angular/core/testing";
4
- import { Router, provideRouter } from "@angular/router";
5
- import { RouterTestingHarness } from "@angular/router/testing";
6
-
7
- //#region src/pure.ts
8
- async function render(componentClass, config) {
9
- const imports = [componentClass, ...config?.imports || []];
10
- const providers = [...config?.providers || []];
11
- const renderResult = {};
12
- if (config?.withRouting) {
13
- const routes = typeof config.withRouting === "boolean" ? [] : config.withRouting.routes;
14
- providers.push(provideRouter(routes));
15
- }
16
- TestBed.configureTestingModule({
17
- imports,
18
- providers
19
- });
20
- if (config?.componentProviders) TestBed.overrideComponent(componentClass, { add: { providers: config.componentProviders } });
21
- if (config?.withRouting) {
22
- renderResult.routerHarness = await RouterTestingHarness.create(typeof config.withRouting === "boolean" ? void 0 : config.withRouting.initialRoute);
23
- renderResult.router = TestBed.inject(Router);
24
- }
25
- const bindings = Object.entries(config?.inputs ?? {}).map(([key, value]) => inputBinding(key, () => value));
26
- const fixture = TestBed.createComponent(componentClass, { bindings });
27
- fixture.autoDetectChanges();
28
- await fixture.whenStable();
29
- const component = page.elementLocator(fixture.nativeElement);
30
- return {
31
- ...renderResult,
32
- fixture,
33
- componentClassInstance: fixture.componentInstance,
34
- component
35
- };
36
- }
37
- function cleanup(shouldTeardown = false) {
38
- return ɵgetCleanupHook(shouldTeardown)();
39
- }
40
-
41
- //#endregion
42
- export { render as n, cleanup as t };
@@ -1,31 +0,0 @@
1
- import { Locator } from "vitest/browser";
2
- import { EnvironmentProviders, InputSignal, Provider, Type } from "@angular/core";
3
- import { ComponentFixture } from "@angular/core/testing";
4
- import { Router, Routes } from "@angular/router";
5
- import { RouterTestingHarness } from "@angular/router/testing";
6
-
7
- //#region src/pure.d.ts
8
- interface RoutingConfig {
9
- routes: Routes;
10
- initialRoute?: string;
11
- }
12
- type Inputs<CMP_TYPE extends Type<unknown>> = Partial<{ [PROP in keyof InstanceType<CMP_TYPE> as InstanceType<CMP_TYPE>[PROP] extends InputSignal<unknown> ? PROP : never]: InstanceType<CMP_TYPE>[PROP] extends InputSignal<infer VALUE> ? VALUE : never }>;
13
- interface RenderConfig<CMP_TYPE extends Type<unknown> = Type<unknown>> {
14
- inputs?: Inputs<CMP_TYPE>;
15
- withRouting?: RoutingConfig | boolean;
16
- providers?: Array<Provider | EnvironmentProviders>;
17
- componentProviders?: Array<Provider>;
18
- imports?: unknown[];
19
- }
20
- interface RenderResult<T> {
21
- fixture: ComponentFixture<T>;
22
- component: Locator;
23
- componentClassInstance: T;
24
- routerHarness?: RouterTestingHarness;
25
- router?: Router;
26
- }
27
- type RenderFn = <T>(component: Type<T>, config?: RenderConfig<Type<T>>) => Promise<RenderResult<T>>;
28
- declare function render<T>(componentClass: Type<T>, config?: RenderConfig<Type<T>>): Promise<RenderResult<T>>;
29
- declare function cleanup(shouldTeardown?: boolean): void;
30
- //#endregion
31
- export { RoutingConfig as a, RenderResult as i, RenderConfig as n, cleanup as o, RenderFn as r, render as s, Inputs as t };