vitest-browser-angular 0.0.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 +4 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +45 -0
- package/dist/setup-RnZmQ_2I.js +10 -0
- package/dist/setup-zones.d.ts +3 -0
- package/dist/setup-zones.js +9 -0
- package/dist/setup.d.ts +4 -0
- package/dist/setup.js +3 -0
- package/package.json +85 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ComponentFixture } from "@angular/core/testing";
|
|
2
|
+
import { Router, Routes } from "@angular/router";
|
|
3
|
+
import { RouterTestingHarness } from "@angular/router/testing";
|
|
4
|
+
import { BrowserPage, Locator } from "@vitest/browser/context";
|
|
5
|
+
import * as vitest0 from "vitest";
|
|
6
|
+
import { Type } from "@angular/core";
|
|
7
|
+
export * from "vitest";
|
|
8
|
+
|
|
9
|
+
//#region src/index.d.ts
|
|
10
|
+
interface RoutingConfig {
|
|
11
|
+
routes: Routes;
|
|
12
|
+
initialRoute?: string;
|
|
13
|
+
}
|
|
14
|
+
interface MountConfig {
|
|
15
|
+
withRouting?: RoutingConfig;
|
|
16
|
+
providers?: any[];
|
|
17
|
+
imports?: any[];
|
|
18
|
+
}
|
|
19
|
+
interface MountResult<T> {
|
|
20
|
+
fixture: ComponentFixture<T>;
|
|
21
|
+
component: Locator;
|
|
22
|
+
componentClassInstance: T;
|
|
23
|
+
routerHarness?: RouterTestingHarness;
|
|
24
|
+
router?: Router;
|
|
25
|
+
}
|
|
26
|
+
type MountFn = <T>(component: Type<T>, config?: MountConfig) => Promise<MountResult<T>>;
|
|
27
|
+
declare const test: vitest0.TestAPI<{
|
|
28
|
+
page: BrowserPage;
|
|
29
|
+
mount: MountFn;
|
|
30
|
+
}>;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { MountFn, MountResult, test };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { TestBed, ɵgetCleanupHook } from "@angular/core/testing";
|
|
2
|
+
import { Router, provideRouter } from "@angular/router";
|
|
3
|
+
import { RouterTestingHarness } from "@angular/router/testing";
|
|
4
|
+
import { page } from "@vitest/browser/context";
|
|
5
|
+
import { test as test$1 } from "vitest";
|
|
6
|
+
|
|
7
|
+
export * from "vitest"
|
|
8
|
+
|
|
9
|
+
//#region src/index.ts
|
|
10
|
+
page.extend({ [Symbol.for("vitest:component-cleanup")]: ɵgetCleanupHook(false) });
|
|
11
|
+
const test = test$1.extend({
|
|
12
|
+
page: async ({}, use) => {
|
|
13
|
+
await use(page);
|
|
14
|
+
},
|
|
15
|
+
mount: async ({ page: page$1 }, use) => {
|
|
16
|
+
await use(async (componentClass, config) => {
|
|
17
|
+
const imports = [componentClass, ...config?.imports || []];
|
|
18
|
+
const providers = [...config?.providers || []];
|
|
19
|
+
const mountResult = {};
|
|
20
|
+
if (config?.withRouting) providers.push(provideRouter(config.withRouting.routes));
|
|
21
|
+
TestBed.configureTestingModule({
|
|
22
|
+
imports,
|
|
23
|
+
providers
|
|
24
|
+
});
|
|
25
|
+
if (config?.withRouting) {
|
|
26
|
+
const routerHarness = await RouterTestingHarness.create(config.withRouting.initialRoute);
|
|
27
|
+
mountResult.routerHarness = routerHarness;
|
|
28
|
+
mountResult.router = TestBed.inject(Router);
|
|
29
|
+
}
|
|
30
|
+
const fixture = TestBed.createComponent(componentClass);
|
|
31
|
+
fixture.autoDetectChanges();
|
|
32
|
+
await fixture.whenStable();
|
|
33
|
+
const component = page$1.elementLocator(fixture.nativeElement);
|
|
34
|
+
return {
|
|
35
|
+
...mountResult,
|
|
36
|
+
fixture,
|
|
37
|
+
componentClassInstance: fixture.componentInstance,
|
|
38
|
+
component
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { test };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getTestBed } from "@angular/core/testing";
|
|
2
|
+
import { BrowserTestingModule, platformBrowserTesting } from "@angular/platform-browser/testing";
|
|
3
|
+
|
|
4
|
+
//#region src/setup.ts
|
|
5
|
+
function setupAngularTestEnvironment() {
|
|
6
|
+
getTestBed().initTestEnvironment(BrowserTestingModule, platformBrowserTesting(), { teardown: { destroyAfterEach: false } });
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { setupAngularTestEnvironment };
|
package/dist/setup.d.ts
ADDED
package/dist/setup.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vitest-browser-angular",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Mount Angular components in VItest Browser Mode",
|
|
5
|
+
"author": "Shai Reznik (HiRez.io)",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/hirezio/vitest-browser-angular#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/hirezio/vitest-browser-angular.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/hirezio/vitest-browser-angular/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"angular",
|
|
17
|
+
"vitest",
|
|
18
|
+
"browser",
|
|
19
|
+
"testing"
|
|
20
|
+
],
|
|
21
|
+
"type": "module",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"default": "./dist/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./setup-zones": {
|
|
28
|
+
"types": "./dist/setup-zones.d.ts",
|
|
29
|
+
"default": "./dist/setup-zones.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"main": "./dist/index.js",
|
|
33
|
+
"module": "./dist/index.js",
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"files": [
|
|
36
|
+
"*.d.ts",
|
|
37
|
+
"*.mjs",
|
|
38
|
+
"dist"
|
|
39
|
+
],
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": "^18.0.0 || ^20.0.0 || >=22.0.0"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsdown",
|
|
45
|
+
"dev": "tsdown --watch --sourcemap",
|
|
46
|
+
"test": "vitest",
|
|
47
|
+
"lint": "eslint --cache .",
|
|
48
|
+
"lint:fix": "pnpm lint --fix"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"@analogjs/vitest-angular": "^1.20.0",
|
|
52
|
+
"@angular/compiler": "^20.0.0",
|
|
53
|
+
"@angular/core": "^20.0.0",
|
|
54
|
+
"@angular/platform-browser": "^20.0.0",
|
|
55
|
+
"@angular/router": "^20.0.0",
|
|
56
|
+
"@vitest/browser": "^2.1.0 || ^3.0.0 || ^4.0.0-0",
|
|
57
|
+
"vitest": "^2.1.0 || ^3.0.0 || ^4.0.0-0"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@analogjs/vitest-angular": "^1.20.2",
|
|
61
|
+
"@angular/compiler": "^20.0.0",
|
|
62
|
+
"@angular/core": "^20.0.0",
|
|
63
|
+
"@angular/platform-browser": "^20.0.0",
|
|
64
|
+
"@angular/router": "^20.0.0",
|
|
65
|
+
"@changesets/cli": "^2.29.6",
|
|
66
|
+
"@changesets/get-github-info": "^0.6.0",
|
|
67
|
+
"@changesets/types": "^6.1.0",
|
|
68
|
+
"@vitest/browser": "^3.2.0",
|
|
69
|
+
"bumpp": "^9.4.2",
|
|
70
|
+
"changelogithub": "^0.13.9",
|
|
71
|
+
"eslint": "^9.8.0",
|
|
72
|
+
"eslint-config-prettier": "^10.1.8",
|
|
73
|
+
"playwright": "^1.46.0",
|
|
74
|
+
"prettier": "^3.6.2",
|
|
75
|
+
"pretty-quick": "^4.2.2",
|
|
76
|
+
"simple-git-hooks": "^2.13.1",
|
|
77
|
+
"tsdown": "^0.14.2",
|
|
78
|
+
"tsup": "^8.2.4",
|
|
79
|
+
"tsx": "^4.17.0",
|
|
80
|
+
"typescript": "^5.5.4",
|
|
81
|
+
"vitest": "^3.2.0",
|
|
82
|
+
"zone.js": "^0.15.1",
|
|
83
|
+
"zx": "^8.1.4"
|
|
84
|
+
}
|
|
85
|
+
}
|