@testforgejs/vue-test-plugin-router 1.0.0-beta.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/LICENSE +8 -0
- package/README.md +68 -0
- package/dist/index.cjs +44 -0
- package/dist/index.d.cts +54 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.js +17 -0
- package/package.json +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
Copyright © 2026 Roman Levchenko
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
5
|
+
|
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# @testforgejs/vue-test-plugin-router
|
|
2
|
+
|
|
3
|
+
Official TestForge plugin for Vue Router integration in component tests.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Choose your preferred package manager.
|
|
8
|
+
|
|
9
|
+
### pnpm
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add -D @testforgejs/vue-test-plugin-router@beta
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### npm
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install -D @testforgejs/vue-test-plugin-router@beta
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Yarn
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
yarn add -D @testforgejs/vue-test-plugin-router@beta
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
> `@testforgejs/vue-test-core` is required.
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
Register `routerPlugin` in the TestForge plugin manifest.
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { createTestFramework } from "@testforgejs/vue-test-core";
|
|
35
|
+
import { routerPlugin } from "@testforgejs/vue-test-plugin-router";
|
|
36
|
+
|
|
37
|
+
const framework = createTestFramework({
|
|
38
|
+
presets: {
|
|
39
|
+
default: {
|
|
40
|
+
manifest: [
|
|
41
|
+
{
|
|
42
|
+
module: routerPlugin,
|
|
43
|
+
enabled: true,
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const factory = framework.testComponentFactory(MyComponent);
|
|
51
|
+
|
|
52
|
+
const wrapper = factory();
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The plugin provides Vue Router integration for components mounted through TestForge.
|
|
56
|
+
|
|
57
|
+
## Supported versions
|
|
58
|
+
|
|
59
|
+
- Vue: 3.x
|
|
60
|
+
- Vue Router: 4.x and 5.x
|
|
61
|
+
|
|
62
|
+
## Documentation
|
|
63
|
+
|
|
64
|
+
See the [TestForge documentation](https://github.com/testforgejs/testforge#readme).
|
|
65
|
+
|
|
66
|
+
### API Reference
|
|
67
|
+
|
|
68
|
+
See the [API reference](https://github.com/testforgejs/testforge/blob/main/packages/vue-test-plugin-router/docs/api/README.md).
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
routerPlugin: () => routerPlugin
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
|
|
27
|
+
// src/module/createRouterPlugin.ts
|
|
28
|
+
var import_vue_test_core = require("@testforgejs/vue-test-core");
|
|
29
|
+
var import_vue_router = require("vue-router");
|
|
30
|
+
function createRouterPlugin(options) {
|
|
31
|
+
return (0, import_vue_test_core.createPluginInstance)(import_vue_router.createRouter, options);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// src/module/routerPlugin.ts
|
|
35
|
+
var routerPlugin = {
|
|
36
|
+
getName: () => "router",
|
|
37
|
+
getDefinition: () => ({
|
|
38
|
+
create: createRouterPlugin
|
|
39
|
+
})
|
|
40
|
+
};
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
43
|
+
routerPlugin
|
|
44
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { RouterOptions, Router } from 'vue-router';
|
|
2
|
+
import { PluginControlOptions, PluginModule } from '@testforgejs/vue-test-core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Configuration options for the Vue Router test plugin.
|
|
6
|
+
*
|
|
7
|
+
* This interface integrates standard router initialization settings
|
|
8
|
+
* and TestForge test kernel control options (such as `expose`).
|
|
9
|
+
*
|
|
10
|
+
* @see {@link RouterOptions} from the `vue-router` package for configuring routes and history.
|
|
11
|
+
* @see {@link PluginControlOptions} from the `@testforgejs/vue-test-core` package for instance interception.
|
|
12
|
+
*/
|
|
13
|
+
interface VueTestRouterOptions extends RouterOptions, PluginControlOptions<Router> {
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Extending TestForge kernel types for Vue Router integration.
|
|
18
|
+
*
|
|
19
|
+
* This module registers the router configuration in the global plugin map,
|
|
20
|
+
* which ensures strict typing when calling `testComponentFactory`.
|
|
21
|
+
*
|
|
22
|
+
* @module Augmentation
|
|
23
|
+
*/
|
|
24
|
+
declare module "@testforgejs/vue-test-core" {
|
|
25
|
+
/**
|
|
26
|
+
* The global interface for the TestForge kernel plugin options.
|
|
27
|
+
*/
|
|
28
|
+
interface PluginOptionsMap {
|
|
29
|
+
/**
|
|
30
|
+
* Configuration for the `router` plugin.
|
|
31
|
+
* Accepts an object of type {@link VueTestRouterOptions} containing Vue router settings and control hooks.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* factory({}, {
|
|
36
|
+
* plugins: {
|
|
37
|
+
* router: {
|
|
38
|
+
* history: createMemoryHistory(),
|
|
39
|
+
* routes: [...]
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
router: VueTestRouterOptions;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A Vue Router plugin module for the TestForge testing framework.
|
|
51
|
+
*/
|
|
52
|
+
declare const routerPlugin: PluginModule<Router, VueTestRouterOptions>;
|
|
53
|
+
|
|
54
|
+
export { type VueTestRouterOptions, routerPlugin };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { RouterOptions, Router } from 'vue-router';
|
|
2
|
+
import { PluginControlOptions, PluginModule } from '@testforgejs/vue-test-core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Configuration options for the Vue Router test plugin.
|
|
6
|
+
*
|
|
7
|
+
* This interface integrates standard router initialization settings
|
|
8
|
+
* and TestForge test kernel control options (such as `expose`).
|
|
9
|
+
*
|
|
10
|
+
* @see {@link RouterOptions} from the `vue-router` package for configuring routes and history.
|
|
11
|
+
* @see {@link PluginControlOptions} from the `@testforgejs/vue-test-core` package for instance interception.
|
|
12
|
+
*/
|
|
13
|
+
interface VueTestRouterOptions extends RouterOptions, PluginControlOptions<Router> {
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Extending TestForge kernel types for Vue Router integration.
|
|
18
|
+
*
|
|
19
|
+
* This module registers the router configuration in the global plugin map,
|
|
20
|
+
* which ensures strict typing when calling `testComponentFactory`.
|
|
21
|
+
*
|
|
22
|
+
* @module Augmentation
|
|
23
|
+
*/
|
|
24
|
+
declare module "@testforgejs/vue-test-core" {
|
|
25
|
+
/**
|
|
26
|
+
* The global interface for the TestForge kernel plugin options.
|
|
27
|
+
*/
|
|
28
|
+
interface PluginOptionsMap {
|
|
29
|
+
/**
|
|
30
|
+
* Configuration for the `router` plugin.
|
|
31
|
+
* Accepts an object of type {@link VueTestRouterOptions} containing Vue router settings and control hooks.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* factory({}, {
|
|
36
|
+
* plugins: {
|
|
37
|
+
* router: {
|
|
38
|
+
* history: createMemoryHistory(),
|
|
39
|
+
* routes: [...]
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
router: VueTestRouterOptions;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A Vue Router plugin module for the TestForge testing framework.
|
|
51
|
+
*/
|
|
52
|
+
declare const routerPlugin: PluginModule<Router, VueTestRouterOptions>;
|
|
53
|
+
|
|
54
|
+
export { type VueTestRouterOptions, routerPlugin };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/module/createRouterPlugin.ts
|
|
2
|
+
import { createPluginInstance } from "@testforgejs/vue-test-core";
|
|
3
|
+
import { createRouter } from "vue-router";
|
|
4
|
+
function createRouterPlugin(options) {
|
|
5
|
+
return createPluginInstance(createRouter, options);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// src/module/routerPlugin.ts
|
|
9
|
+
var routerPlugin = {
|
|
10
|
+
getName: () => "router",
|
|
11
|
+
getDefinition: () => ({
|
|
12
|
+
create: createRouterPlugin
|
|
13
|
+
})
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
routerPlugin
|
|
17
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@testforgejs/vue-test-plugin-router",
|
|
3
|
+
"version": "1.0.0-beta.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Official TestForge plugin for Vue Router integration in component tests",
|
|
6
|
+
"homepage": "https://github.com/testforgejs/testforge#readme",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/testforgejs/testforge.git",
|
|
10
|
+
"directory": "packages/vue-test-plugin-router"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/testforgejs/testforge/issues"
|
|
14
|
+
},
|
|
15
|
+
"main": "./dist/index.cjs",
|
|
16
|
+
"module": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js",
|
|
22
|
+
"require": "./dist/index.cjs"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"vue",
|
|
33
|
+
"vue3",
|
|
34
|
+
"testing",
|
|
35
|
+
"component-testing",
|
|
36
|
+
"vue-test-utils",
|
|
37
|
+
"vue-router",
|
|
38
|
+
"router",
|
|
39
|
+
"routing",
|
|
40
|
+
"navigation",
|
|
41
|
+
"testforge",
|
|
42
|
+
"testforge-plugin"
|
|
43
|
+
],
|
|
44
|
+
"license": "MIT",
|
|
45
|
+
"author": "Roman Levchenko",
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"vue-router": ">=4.0.0 <6.0.0",
|
|
48
|
+
"@testforgejs/vue-test-core": "1.0.0-beta.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"vue-router": "^5.0.0",
|
|
52
|
+
"@testforgejs/vue-test-core": "1.0.0-beta.0"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "tsup",
|
|
56
|
+
"dev": "tsup --watch",
|
|
57
|
+
"test:types": "tsd",
|
|
58
|
+
"docs:generate": "typedoc"
|
|
59
|
+
}
|
|
60
|
+
}
|