@testforgejs/vue-test-plugin-i18n 1.0.0-beta.2 → 1.0.0-beta.3

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
@@ -24,10 +24,56 @@ npm install -D @testforgejs/vue-test-plugin-i18n@beta
24
24
  yarn add -D @testforgejs/vue-test-plugin-i18n@beta
25
25
  ```
26
26
 
27
- > `@testforgejs/vue-test-core` is required.
27
+ > `@testforgejs/vue-test-core` and `vue-i18n` are required.
28
28
 
29
29
  ## Usage
30
30
 
31
+ ### Using plugin defaults
32
+
33
+ The plugin provides a project-independent default configuration through `getDefaultOptions()`:
34
+
35
+ ```typescript
36
+ import { createTestFramework } from "@testforgejs/vue-test-core";
37
+ import { i18nPlugin } from "@testforgejs/vue-test-plugin-i18n";
38
+
39
+ const framework = createTestFramework({
40
+ presets: {
41
+ default: {
42
+ manifest: [
43
+ {
44
+ module: i18nPlugin,
45
+ enabled: true,
46
+ },
47
+ ],
48
+ defaults: {
49
+ i18n: i18nPlugin.getDefaultOptions(),
50
+ },
51
+ },
52
+ },
53
+ });
54
+ ```
55
+
56
+ `getDefaultOptions()` returns an options factory suitable for use in a preset.
57
+
58
+ The plugin-provided defaults are equivalent to:
59
+
60
+ ```typescript
61
+ {
62
+ legacy: false,
63
+ globalInjection: true,
64
+ }
65
+ ```
66
+
67
+ These defaults configure Vue I18n to use Composition API mode and make the global Composer properties and functions available to components through Vue's global properties.
68
+
69
+ The plugin intentionally does not define application-specific localization behavior such as the active locale, fallback locale, messages, formats, or warning policy.
70
+
71
+ Plugin defaults are **not applied automatically**. Adding the plugin to a preset manifest declares that the plugin is available and whether it is enabled; the preset explicitly decides whether to use the plugin-provided defaults or provide its own configuration.
72
+
73
+ ### Providing custom options
74
+
75
+ You can define the Vue I18n configuration directly in the preset instead:
76
+
31
77
  ```typescript
32
78
  import { createTestFramework } from "@testforgejs/vue-test-core";
33
79
  import { i18nPlugin } from "@testforgejs/vue-test-plugin-i18n";
@@ -44,7 +90,14 @@ const framework = createTestFramework({
44
90
  defaults: {
45
91
  i18n: () => ({
46
92
  legacy: false,
93
+ globalInjection: true,
47
94
  locale: "en",
95
+ fallbackLocale: "en",
96
+ messages: {
97
+ en: {
98
+ hello: "Hello",
99
+ },
100
+ },
48
101
  }),
49
102
  },
50
103
  },
@@ -52,12 +105,138 @@ const framework = createTestFramework({
52
105
  });
53
106
  ```
54
107
 
55
- `defaults.i18n` is an options factory. Each invocation produces a fresh Vue I18n options object for the current pipeline context.
108
+ Using `getDefaultOptions()` is optional. Define custom defaults when tests require application-specific locales, messages, fallback behavior, formatting, warning policy, or other Vue I18n configuration.
109
+
110
+ ## Configuration
111
+
112
+ ### Vue I18n options
113
+
114
+ The plugin integrates TestForge with Vue I18n by creating a Vue I18n instance from the provided `createI18n()` options.
115
+
116
+ Configuration fields such as `legacy`, `globalInjection`, `locale`, `fallbackLocale`, `messages`, `missingWarn`, and `fallbackWarn` belong to Vue I18n.
117
+
118
+ TestForge does not define an alternative configuration format for Vue I18n. The integration passes these options to Vue I18n when creating the plugin instance.
119
+
120
+ Refer to the Vue I18n documentation for the complete set of supported `createI18n()` options and their behavior.
121
+
122
+ ### TestForge plugin defaults
123
+
124
+ The defaults provided by this package intentionally contain only:
125
+
126
+ ```typescript
127
+ {
128
+ legacy: false,
129
+ globalInjection: true,
130
+ }
131
+ ```
132
+
133
+ `legacy: false` selects Vue I18n's Composition API mode. This provides a modern Vue 3 integration and allows components to use APIs such as `useI18n()`.
134
+
135
+ `globalInjection: true` makes global Composer properties and functions such as `$t`, `$d`, and `$n` available to components through Vue's global properties.
136
+
137
+ Setting `globalInjection` explicitly also provides consistent behavior across the supported Vue I18n versions instead of depending on version-specific defaults.
138
+
139
+ The plugin does not explicitly configure:
140
+
141
+ ```typescript
142
+ locale;
143
+ fallbackLocale;
144
+ messages;
145
+ missingWarn;
146
+ fallbackWarn;
147
+ ```
148
+
149
+ These options therefore retain the behavior defined by Vue I18n unless a preset provides them explicitly.
150
+
151
+ This keeps plugin defaults project-independent and avoids TestForge choosing an application locale, translation catalog, fallback strategy, or warning policy.
152
+
153
+ For example, a project-specific preset can provide its actual localization configuration:
154
+
155
+ ```typescript
156
+ defaults: {
157
+ i18n: () => ({
158
+ legacy: false,
159
+ globalInjection: true,
160
+ locale: "en",
161
+ fallbackLocale: "en",
162
+ messages: {
163
+ en: {
164
+ hello: "Hello",
165
+ },
166
+ },
167
+ }),
168
+ },
169
+ ```
170
+
171
+ If a test environment intentionally needs to suppress missing-translation or fallback warnings, that policy can also be configured explicitly:
172
+
173
+ ```typescript
174
+ defaults: {
175
+ i18n: () => ({
176
+ legacy: false,
177
+ globalInjection: true,
178
+ missingWarn: false,
179
+ fallbackWarn: false,
180
+ }),
181
+ },
182
+ ```
183
+
184
+ ### Options factories
185
+
186
+ Preset defaults are defined as factories:
187
+
188
+ ```typescript
189
+ defaults: {
190
+ i18n: () => ({
191
+ legacy: false,
192
+ globalInjection: true,
193
+ }),
194
+ },
195
+ ```
196
+
197
+ Each invocation of the factory produces a fresh options object for the current TestForge pipeline execution.
198
+
199
+ `i18nPlugin.getDefaultOptions()` follows the same contract: it returns an options factory rather than a shared options object.
200
+
201
+ This allows presets to choose explicitly between:
202
+
203
+ - the project-independent defaults provided by the plugin; and
204
+ - a custom Vue I18n configuration defined by the preset.
205
+
206
+ ## Package exports
207
+
208
+ The package provides both descriptive and standardized plugin exports:
209
+
210
+ ```typescript
211
+ import { i18nPlugin, plugin, PLUGIN_NAME } from "@testforgejs/vue-test-plugin-i18n";
212
+ ```
213
+
214
+ ### `i18nPlugin`
215
+
216
+ The descriptive Vue I18n plugin module export.
217
+
218
+ ### `plugin`
219
+
220
+ The standardized plugin module export.
221
+
222
+ It references the same plugin module as `i18nPlugin` and provides a consistent package-level API across TestForge plugin packages.
223
+
224
+ ### `PLUGIN_NAME`
225
+
226
+ The standardized plugin identifier export.
227
+
228
+ For this package:
229
+
230
+ ```typescript
231
+ PLUGIN_NAME === "i18n";
232
+ ```
233
+
234
+ The standardized `plugin` and `PLUGIN_NAME` exports are useful for tooling and other code that works with TestForge plugin packages generically.
56
235
 
57
236
  ## Supported versions
58
237
 
59
- - Vue I18n: 9–11
60
- - Vue: 3.x
238
+ - Vue: 3.3.0 or higher
239
+ - Vue I18n: 9.x, 10.x, and 11.x
61
240
 
62
241
  ## Documentation
63
242
 
package/dist/index.cjs CHANGED
@@ -20,7 +20,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
- i18nPlugin: () => i18nPlugin
23
+ PLUGIN_NAME: () => I18N_PLUGIN_NAME,
24
+ i18nPlugin: () => i18nPlugin,
25
+ plugin: () => i18nPlugin
24
26
  });
25
27
  module.exports = __toCommonJS(index_exports);
26
28
 
@@ -31,14 +33,26 @@ function createI18nPlugin(options) {
31
33
  return (0, import_vue_test_core.createPluginInstance)(import_vue_i18n.createI18n, options);
32
34
  }
33
35
 
36
+ // src/defaults.ts
37
+ var defaultOptions = () => () => ({
38
+ legacy: false,
39
+ globalInjection: true
40
+ });
41
+
42
+ // src/constants/constants.ts
43
+ var I18N_PLUGIN_NAME = "i18n";
44
+
34
45
  // src/module/i18nPlugin.ts
35
46
  var i18nPlugin = {
36
- getName: () => "i18n",
47
+ getName: () => I18N_PLUGIN_NAME,
37
48
  getDefinition: () => ({
38
49
  create: createI18nPlugin
39
- })
50
+ }),
51
+ getDefaultOptions: defaultOptions
40
52
  };
41
53
  // Annotate the CommonJS export names for ESM import in node:
42
54
  0 && (module.exports = {
43
- i18nPlugin
55
+ PLUGIN_NAME,
56
+ i18nPlugin,
57
+ plugin
44
58
  });
package/dist/index.d.cts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { I18nOptions, I18n } from 'vue-i18n';
2
- import { PluginControlOptions, PluginModule } from '@testforgejs/vue-test-core';
2
+ import { PluginControlOptions, PluginModuleWithDefaults } from '@testforgejs/vue-test-core';
3
+
4
+ declare const I18N_PLUGIN_NAME: "i18n";
3
5
 
4
6
  /**
5
7
  * Configuration options for the Vue I18n test plugin.
@@ -41,7 +43,7 @@ declare module "@testforgejs/vue-test-core" {
41
43
  * });
42
44
  * ```
43
45
  */
44
- i18n: VueTestI18nOptions;
46
+ [I18N_PLUGIN_NAME]: VueTestI18nOptions;
45
47
  }
46
48
  }
47
49
 
@@ -49,6 +51,6 @@ declare module "@testforgejs/vue-test-core" {
49
51
  * Vue I18n plugin module definition for the TestForge framework.
50
52
  * Automatically handles internationalization setup inside test environments.
51
53
  */
52
- declare const i18nPlugin: PluginModule<I18n, VueTestI18nOptions>;
54
+ declare const i18nPlugin: PluginModuleWithDefaults<I18n, VueTestI18nOptions>;
53
55
 
54
- export { type VueTestI18nOptions, i18nPlugin };
56
+ export { I18N_PLUGIN_NAME as PLUGIN_NAME, type VueTestI18nOptions, i18nPlugin, i18nPlugin as plugin };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { I18nOptions, I18n } from 'vue-i18n';
2
- import { PluginControlOptions, PluginModule } from '@testforgejs/vue-test-core';
2
+ import { PluginControlOptions, PluginModuleWithDefaults } from '@testforgejs/vue-test-core';
3
+
4
+ declare const I18N_PLUGIN_NAME: "i18n";
3
5
 
4
6
  /**
5
7
  * Configuration options for the Vue I18n test plugin.
@@ -41,7 +43,7 @@ declare module "@testforgejs/vue-test-core" {
41
43
  * });
42
44
  * ```
43
45
  */
44
- i18n: VueTestI18nOptions;
46
+ [I18N_PLUGIN_NAME]: VueTestI18nOptions;
45
47
  }
46
48
  }
47
49
 
@@ -49,6 +51,6 @@ declare module "@testforgejs/vue-test-core" {
49
51
  * Vue I18n plugin module definition for the TestForge framework.
50
52
  * Automatically handles internationalization setup inside test environments.
51
53
  */
52
- declare const i18nPlugin: PluginModule<I18n, VueTestI18nOptions>;
54
+ declare const i18nPlugin: PluginModuleWithDefaults<I18n, VueTestI18nOptions>;
53
55
 
54
- export { type VueTestI18nOptions, i18nPlugin };
56
+ export { I18N_PLUGIN_NAME as PLUGIN_NAME, type VueTestI18nOptions, i18nPlugin, i18nPlugin as plugin };
package/dist/index.js CHANGED
@@ -5,13 +5,25 @@ function createI18nPlugin(options) {
5
5
  return createPluginInstance(createI18n, options);
6
6
  }
7
7
 
8
+ // src/defaults.ts
9
+ var defaultOptions = () => () => ({
10
+ legacy: false,
11
+ globalInjection: true
12
+ });
13
+
14
+ // src/constants/constants.ts
15
+ var I18N_PLUGIN_NAME = "i18n";
16
+
8
17
  // src/module/i18nPlugin.ts
9
18
  var i18nPlugin = {
10
- getName: () => "i18n",
19
+ getName: () => I18N_PLUGIN_NAME,
11
20
  getDefinition: () => ({
12
21
  create: createI18nPlugin
13
- })
22
+ }),
23
+ getDefaultOptions: defaultOptions
14
24
  };
15
25
  export {
16
- i18nPlugin
26
+ I18N_PLUGIN_NAME as PLUGIN_NAME,
27
+ i18nPlugin,
28
+ i18nPlugin as plugin
17
29
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testforgejs/vue-test-plugin-i18n",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.3",
4
4
  "type": "module",
5
5
  "description": "Official TestForge plugin for vue-i18n integration in component tests",
6
6
  "homepage": "https://github.com/testforgejs/testforge#readme",
@@ -44,11 +44,17 @@
44
44
  "author": "Roman Levchenko",
45
45
  "peerDependencies": {
46
46
  "vue-i18n": ">=9.0.0 <12.0.0",
47
- "@testforgejs/vue-test-core": "1.0.0-beta.2"
47
+ "@testforgejs/vue-test-core": "1.0.0-beta.3"
48
48
  },
49
49
  "devDependencies": {
50
50
  "vue-i18n": "^11.4.8",
51
- "@testforgejs/vue-test-core": "1.0.0-beta.2"
51
+ "@testforgejs/vue-test-core": "1.0.0-beta.3"
52
+ },
53
+ "testforge": {
54
+ "plugin": {
55
+ "schemaVersion": 1,
56
+ "displayName": "Vue I18n"
57
+ }
52
58
  },
53
59
  "scripts": {
54
60
  "build": "tsup",