@testforgejs/vue-test-plugin-pinia 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 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,64 @@
1
+ # @testforgejs/vue-test-plugin-pinia
2
+
3
+ Pinia integration for TestForge 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-pinia@beta
13
+ ```
14
+
15
+ ### npm
16
+
17
+ ```bash
18
+ npm install -D @testforgejs/vue-test-plugin-pinia@beta
19
+ ```
20
+
21
+ ### Yarn
22
+
23
+ ```bash
24
+ yarn add -D @testforgejs/vue-test-plugin-pinia@beta
25
+ ```
26
+
27
+ > `@testforgejs/vue-test-core` is required.
28
+
29
+ ## Usage
30
+
31
+ Register `piniaPlugin` in the TestForge plugin manifest.
32
+
33
+ ```ts
34
+ import { createTestFramework } from "@testforgejs/vue-test-core";
35
+ import { piniaPlugin } from "@testforgejs/vue-test-plugin-pinia";
36
+
37
+ const framework = createTestFramework({
38
+ presets: {
39
+ default: {
40
+ manifest: [
41
+ {
42
+ module: piniaPlugin,
43
+ enabled: true,
44
+ },
45
+ ],
46
+ },
47
+ },
48
+ });
49
+ ```
50
+
51
+ The plugin provides a Pinia instance for components mounted through TestForge.
52
+
53
+ ## Supported versions
54
+
55
+ - Vue: 3.x
56
+ - Pinia: 3.x
57
+
58
+ ## Documentation
59
+
60
+ See the [TestForge documentation](https://github.com/testforgejs/testforge#readme).
61
+
62
+ ### API Reference
63
+
64
+ See the [API reference](https://github.com/testforgejs/testforge/blob/main/packages/vue-test-plugin-pinia/docs/api/README.md).
package/dist/index.cjs ADDED
@@ -0,0 +1,59 @@
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
+ piniaPlugin: () => piniaPlugin
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+
27
+ // src/module/createPiniaPlugin.ts
28
+ var import_vue_test_core = require("@testforgejs/vue-test-core");
29
+ var import_testing = require("@pinia/testing");
30
+ function createPiniaPlugin(options) {
31
+ const pinia = (0, import_vue_test_core.createPluginInstance)(import_testing.createTestingPinia, options);
32
+ if (options.mockStores) {
33
+ options.mockStores(pinia);
34
+ }
35
+ return pinia;
36
+ }
37
+
38
+ // src/module/piniaPlugin.ts
39
+ var import_pinia = require("pinia");
40
+ var piniaPlugin = {
41
+ getName: () => "pinia",
42
+ getDefinition: () => ({
43
+ // beforeCreate(ctx, options) {
44
+ // return {
45
+ // ...defaultPinia,
46
+ // ...options,
47
+ // }
48
+ // },
49
+ create: createPiniaPlugin,
50
+ // Automatically sets the active Pinia instance for current test context.
51
+ afterCreate(instance) {
52
+ (0, import_pinia.setActivePinia)(instance);
53
+ }
54
+ })
55
+ };
56
+ // Annotate the CommonJS export names for ESM import in node:
57
+ 0 && (module.exports = {
58
+ piniaPlugin
59
+ });
@@ -0,0 +1,65 @@
1
+ import { Pinia } from 'pinia';
2
+ import { TestingOptions } from '@pinia/testing';
3
+ import { PluginControlOptions, PluginModule } from '@testforgejs/vue-test-core';
4
+
5
+ /**
6
+ * A callback function to mutate or configure Pinia stores immediately after they are created.
7
+ * Used to set the initial state (mocking) in tests.
8
+ *
9
+ * @param pinia - Созданный инстанс Pinia для тестирования.
10
+ */
11
+ type MockStoresFn = (pinia: Pinia) => void;
12
+ /**
13
+ * Configuration options for the Pinia test plugin.
14
+ *
15
+ * This interface integrates the standard Pinia testing initialization settings
16
+ * (`TestingOptions` from `@pinia/testing`) with the TestForge core configuration options.
17
+ *
18
+ * @see {@link TestingOptions} to configure action stubs and the initial state.
19
+ * @see {@link PluginControlOptions} to use interception methods such as `expose`.
20
+ */
21
+ interface VueTestPiniaOptions extends TestingOptions, PluginControlOptions<Pinia> {
22
+ /**
23
+ * A callback function to modify the state of stores before a component is mounted.
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * factory({}, {
28
+ * plugins: {
29
+ * pinia: {
30
+ * mockStores: (pinia) => {
31
+ * const store = useCounterStore(pinia);
32
+ * store.count = 42;
33
+ * }
34
+ * }
35
+ * }
36
+ * });
37
+ * ```
38
+ */
39
+ mockStores?: MockStoresFn;
40
+ }
41
+
42
+ /**
43
+ * Extending TestForge kernel types for Pinia integration.
44
+ *
45
+ * This module registers the Pinia configuration in the global plugin map,
46
+ * which ensures strict typing of the `pinia` property within `plugins`.
47
+ *
48
+ * @module PiniaAugmentation
49
+ */
50
+ declare module "@testforgejs/vue-test-core" {
51
+ /**
52
+ * The global interface for the TestForge kernel plugin options.
53
+ */
54
+ interface PluginOptionsMap {
55
+ /**
56
+ * Configuration for the `pinia` plugin.
57
+ * Accepts an object of type {@link VueTestPiniaOptions}, which controls the behavior of the stores in tests.
58
+ */
59
+ pinia: VueTestPiniaOptions;
60
+ }
61
+ }
62
+
63
+ declare const piniaPlugin: PluginModule<Pinia, VueTestPiniaOptions>;
64
+
65
+ export { type MockStoresFn, type VueTestPiniaOptions, piniaPlugin };
@@ -0,0 +1,65 @@
1
+ import { Pinia } from 'pinia';
2
+ import { TestingOptions } from '@pinia/testing';
3
+ import { PluginControlOptions, PluginModule } from '@testforgejs/vue-test-core';
4
+
5
+ /**
6
+ * A callback function to mutate or configure Pinia stores immediately after they are created.
7
+ * Used to set the initial state (mocking) in tests.
8
+ *
9
+ * @param pinia - Созданный инстанс Pinia для тестирования.
10
+ */
11
+ type MockStoresFn = (pinia: Pinia) => void;
12
+ /**
13
+ * Configuration options for the Pinia test plugin.
14
+ *
15
+ * This interface integrates the standard Pinia testing initialization settings
16
+ * (`TestingOptions` from `@pinia/testing`) with the TestForge core configuration options.
17
+ *
18
+ * @see {@link TestingOptions} to configure action stubs and the initial state.
19
+ * @see {@link PluginControlOptions} to use interception methods such as `expose`.
20
+ */
21
+ interface VueTestPiniaOptions extends TestingOptions, PluginControlOptions<Pinia> {
22
+ /**
23
+ * A callback function to modify the state of stores before a component is mounted.
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * factory({}, {
28
+ * plugins: {
29
+ * pinia: {
30
+ * mockStores: (pinia) => {
31
+ * const store = useCounterStore(pinia);
32
+ * store.count = 42;
33
+ * }
34
+ * }
35
+ * }
36
+ * });
37
+ * ```
38
+ */
39
+ mockStores?: MockStoresFn;
40
+ }
41
+
42
+ /**
43
+ * Extending TestForge kernel types for Pinia integration.
44
+ *
45
+ * This module registers the Pinia configuration in the global plugin map,
46
+ * which ensures strict typing of the `pinia` property within `plugins`.
47
+ *
48
+ * @module PiniaAugmentation
49
+ */
50
+ declare module "@testforgejs/vue-test-core" {
51
+ /**
52
+ * The global interface for the TestForge kernel plugin options.
53
+ */
54
+ interface PluginOptionsMap {
55
+ /**
56
+ * Configuration for the `pinia` plugin.
57
+ * Accepts an object of type {@link VueTestPiniaOptions}, which controls the behavior of the stores in tests.
58
+ */
59
+ pinia: VueTestPiniaOptions;
60
+ }
61
+ }
62
+
63
+ declare const piniaPlugin: PluginModule<Pinia, VueTestPiniaOptions>;
64
+
65
+ export { type MockStoresFn, type VueTestPiniaOptions, piniaPlugin };
package/dist/index.js ADDED
@@ -0,0 +1,32 @@
1
+ // src/module/createPiniaPlugin.ts
2
+ import { createPluginInstance } from "@testforgejs/vue-test-core";
3
+ import { createTestingPinia } from "@pinia/testing";
4
+ function createPiniaPlugin(options) {
5
+ const pinia = createPluginInstance(createTestingPinia, options);
6
+ if (options.mockStores) {
7
+ options.mockStores(pinia);
8
+ }
9
+ return pinia;
10
+ }
11
+
12
+ // src/module/piniaPlugin.ts
13
+ import { setActivePinia } from "pinia";
14
+ var piniaPlugin = {
15
+ getName: () => "pinia",
16
+ getDefinition: () => ({
17
+ // beforeCreate(ctx, options) {
18
+ // return {
19
+ // ...defaultPinia,
20
+ // ...options,
21
+ // }
22
+ // },
23
+ create: createPiniaPlugin,
24
+ // Automatically sets the active Pinia instance for current test context.
25
+ afterCreate(instance) {
26
+ setActivePinia(instance);
27
+ }
28
+ })
29
+ };
30
+ export {
31
+ piniaPlugin
32
+ };
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@testforgejs/vue-test-plugin-pinia",
3
+ "version": "1.0.0-beta.0",
4
+ "type": "module",
5
+ "description": "Official TestForge plugin for Pinia 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-pinia"
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
+ "pinia",
38
+ "state-management",
39
+ "stores",
40
+ "testforge",
41
+ "testforge-plugin"
42
+ ],
43
+ "license": "MIT",
44
+ "author": "Roman Levchenko",
45
+ "peerDependencies": {
46
+ "pinia": ">=3.0.0 <5.0.0",
47
+ "@pinia/testing": ">=1.0.0 <3.0.0",
48
+ "@testforgejs/vue-test-core": "1.0.0-beta.0"
49
+ },
50
+ "devDependencies": {
51
+ "pinia": "^4.0.0",
52
+ "@pinia/testing": "^2.0.0",
53
+ "@testforgejs/vue-test-core": "1.0.0-beta.0"
54
+ },
55
+ "scripts": {
56
+ "build": "tsup",
57
+ "dev": "tsup --watch",
58
+ "test:types": "tsd",
59
+ "docs:generate": "typedoc"
60
+ }
61
+ }