@equinor/fusion-framework-vitest-plugin-react-app 1.0.0-next.5 → 1.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/CHANGELOG.md +52 -154
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +12 -12
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,154 +1,52 @@
|
|
|
1
1
|
# @equinor/fusion-framework-vitest-plugin-react-app
|
|
2
2
|
|
|
3
|
-
## 1.0.0
|
|
3
|
+
## 1.0.0
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
mock by default, with no flags enabled, so `useFeature` needs no `localStorage` or URL
|
|
9
|
-
seeding in tests.
|
|
7
|
+
- f663b46: Add `@equinor/fusion-framework-vitest-plugin-react-app`: Vitest/`vitest-browser-react` helpers for testing a Fusion Framework React application inside a real, mock-backed application module scope — the same `FrameworkProvider` + `ModuleProvider` nesting `renderApp`/`createComponent` wire up in production, backed by `mockFramework` and `mockAppModules` (`@equinor/fusion-framework-app/mock`).
|
|
10
8
|
|
|
11
|
-
`@equinor/fusion-framework-module-feature-flag` is an optional peer dependency: the mock is
|
|
12
|
-
only wired up when the package is actually installed, so apps that don't use feature flags
|
|
13
|
-
aren't forced to add it. Install it to get the default mock; call `enableFeatureFlagMock`
|
|
14
|
-
again inside `configureFusion` to seed specific flags.
|
|
15
|
-
|
|
16
|
-
### Patch Changes
|
|
17
|
-
|
|
18
|
-
- 1813f8a: Exclude `.d.ts` files from the default `server.warmup.clientFiles` and `optimizeDeps.entries`
|
|
19
|
-
globs in `defineProject`. Previously, an app shipping a CJS-style declaration file (for example
|
|
20
|
-
one using `export =`) failed the Vite warmup scan, since it was loaded as ESM.
|
|
21
|
-
- 1813f8a: Revert the mocked framework's default navigation history from browser history back to in-memory
|
|
22
|
-
history. Browser history leaked URL/history state between tests; `configureFusion`/`enableNavigation`
|
|
23
|
-
can still opt back into browser history for a test that specifically needs it.
|
|
24
|
-
- Updated dependencies [c8008e3]
|
|
25
|
-
- @equinor/fusion-framework-app@13.0.3-next.0
|
|
26
|
-
- @equinor/fusion-framework-cli@15.2.11-next.0
|
|
27
|
-
- @equinor/fusion-framework-module-app@8.0.6-next.0
|
|
28
|
-
- @equinor/fusion-framework-module-navigation@7.0.9-next.0
|
|
29
|
-
- @equinor/fusion-framework-react@9.0.0-next.0
|
|
30
|
-
- @equinor/fusion-framework-module-feature-flag@2.1.0-next.0
|
|
31
|
-
|
|
32
|
-
## 1.0.0-next.4
|
|
33
|
-
|
|
34
|
-
### Major Changes
|
|
35
|
-
|
|
36
|
-
- b3d46e0: Rename the `testApp`/`test` fixtures for extending the mocked application and parent framework
|
|
37
|
-
configuration: `configure` is now `configureApp`, the new `configureFramework` fixture
|
|
38
|
-
introduced alongside it is now `configureFusion`, and `env` is now `appEnv`.
|
|
39
|
-
|
|
40
|
-
```diff
|
|
41
|
-
-const test = testApp.extend('configure', { injected: true }, () => ...);
|
|
42
|
-
+const test = testApp.extend('configureApp', { injected: true }, () => ...);
|
|
43
|
-
|
|
44
|
-
-test.override('fusion', async ({ env }) => ...);
|
|
45
|
-
+test.override('fusion', async ({ appEnv }) => ...);
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
`configureFusion` composes with the base parent-framework mock (app manifest and navigation) the same way `configureApp` composes with the base app-module mock — see [Advanced usage](docs/advanced.md#extend-the-parent-framework-mock-with-configurefusion) for extending framework-scope modules such as feature flags, service discovery, or navigation history.
|
|
49
|
-
|
|
50
|
-
Also adds `mergeEnvConfig`, a new utility exported from the `/test` entry point for overriding one endpoint's URL (or an `environment` value) on `appEnv` without dropping the rest of the app's `AppConfig` — a plain object spread over `AppConfig` copies nothing, since it stores `environment`/`endpoints` behind private fields exposed only through getters. See [Advanced usage](docs/advanced.md#fake-an-endpoint-url-with-mergeenvconfig).
|
|
51
|
-
|
|
52
|
-
```ts
|
|
53
|
-
const test = baseTest.extend("appEnv", ({ appEnv }) =>
|
|
54
|
-
mergeEnvConfig(appEnv, {
|
|
55
|
-
endpoints: { "cpr-api": { url: backendBaseUrl } },
|
|
56
|
-
}),
|
|
57
|
-
);
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## 0.2.0-next.3
|
|
61
|
-
|
|
62
|
-
### Patch Changes
|
|
63
|
-
|
|
64
|
-
- @equinor/fusion-framework-cli@15.2.8-next.2
|
|
65
|
-
- @equinor/fusion-framework-app@14.0.0-next.1
|
|
66
|
-
- @equinor/fusion-framework@8.1.0-next.1
|
|
67
|
-
|
|
68
|
-
## 0.2.0-next.2
|
|
69
|
-
|
|
70
|
-
### Minor Changes
|
|
71
|
-
|
|
72
|
-
- 7cdd512: `defineProject` now defaults `test.browser.viewport` to `1024x768` instead of Vitest's own
|
|
73
|
-
mobile-sized default, matching the low, fixed resolution most Fusion apps see in production
|
|
74
|
-
through Citrix. Pass `test.browser.viewport` to `defineProject` to use a different size.
|
|
75
|
-
|
|
76
|
-
## 0.2.0-next.1
|
|
77
|
-
|
|
78
|
-
### Patch Changes
|
|
79
|
-
|
|
80
|
-
- @equinor/fusion-framework-cli@15.2.8-next.1
|
|
81
|
-
|
|
82
|
-
## 0.2.0-next.0
|
|
83
|
-
|
|
84
|
-
### Minor Changes
|
|
85
|
-
|
|
86
|
-
- 2836e0b: Add a `/config` entry-point exporting `defineProject`: a drop-in for Vitest's own `defineProject`, pre-wired with `appTestVitePlugin` and the `@vitest/browser-playwright`/`chromium` browser provider, so a consuming app's own `vitest.config.ts` needs no browser-provider boilerplate.
|
|
87
|
-
|
|
88
|
-
```ts
|
|
89
|
-
import { defineProject } from "@equinor/fusion-framework-vitest-plugin-react-app/config";
|
|
90
|
-
import { name, version } from "./package.json" with { type: "json" };
|
|
91
|
-
|
|
92
|
-
export default defineProject({ test: { name: `${name}@${version}` } });
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
`override` is deep-merged onto the default config via Vite's own `mergeConfig` (a plain object), or applied to the default config outright (a function receiving it) — for changes `mergeConfig` can't express, such as swapping `test.browser.provider` for a different `@vitest/browser-*` provider.
|
|
96
|
-
|
|
97
|
-
`@vitest/browser-playwright` and `playwright` are now explicit peer dependencies of the package.
|
|
98
|
-
|
|
99
|
-
Also fixes `appTestVitePlugin`'s `entrypoint` inference: when no `entrypoint` option is given, it now resolves from the Vitest project's own root (via `configResolved`) instead of `process.cwd()`, so each cookbook's `vitest.config.ts` no longer needs to pass `entrypoint` explicitly when run as part of a multi-project Vitest run.
|
|
100
|
-
|
|
101
|
-
- 2836e0b: Add `@equinor/fusion-framework-vitest-plugin-react-app`: Vitest/`vitest-browser-react` helpers for testing a Fusion Framework React application inside a real, mock-backed application module scope — the same `FrameworkProvider` + `ModuleProvider` nesting `renderApp`/`createComponent` wire up in production, backed by `mockFramework` and `mockAppModules` (`@equinor/fusion-framework-app/mock`).
|
|
102
|
-
|
|
103
9
|
```tsx
|
|
104
|
-
import { renderAppHook } from
|
|
105
|
-
import { useAccessToken } from
|
|
106
|
-
|
|
107
|
-
const { result } = await renderAppHook(() =>
|
|
108
|
-
useAccessToken({ scopes: ["User.Read"] }),
|
|
109
|
-
);
|
|
10
|
+
import { renderAppHook } from '@equinor/fusion-framework-vitest-plugin-react-app';
|
|
11
|
+
import { useAccessToken } from '@equinor/fusion-framework-react-app/msal';
|
|
12
|
+
|
|
13
|
+
const { result } = await renderAppHook(() => useAccessToken({ scopes: ['User.Read'] }));
|
|
110
14
|
await vi.waitFor(() => expect(result.current.pending).toBe(false));
|
|
111
15
|
```
|
|
112
|
-
|
|
16
|
+
|
|
113
17
|
Highlights:
|
|
114
|
-
|
|
18
|
+
|
|
115
19
|
- `renderAppHook`/`renderAppComponent` — render a hook or component against the real `event`/`http`/`msal` module pipeline, with only the network boundary faked; the result carries a nested `fusion: { framework, app }` for driving a module directly after the initial render.
|
|
116
|
-
- `testApp` — a `vitest` `test` extended with `
|
|
117
|
-
- `appTestVitePlugin` — a Vite plugin resolving an application's own manifest, config, and module-configurator (the same pipeline `ffc app build`/`ffc app dev` use) as virtual modules.
|
|
118
|
-
- A `/test` entry-point exporting `test`/`render`, pre-seeded from the resolved manifest/config/configure once `appTestVitePlugin` is registered — no per-test `env`/`configure` wiring
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
20
|
+
- `testApp` — a `vitest` `test` extended with `appEnv`/`configureApp`/`configureFusion`/`app`/`render`/`renderHook` fixtures, for a test file whose cases share one mocked scope. `configureApp` composes with the base app-module mock; `configureFusion` composes with the base parent-framework mock (app manifest and navigation) for extending framework-scope modules such as feature flags, service discovery, or navigation history.
|
|
21
|
+
- `appTestVitePlugin` — a Vite plugin resolving an application's own manifest, config, and module-configurator (the same pipeline `ffc app build`/`ffc app dev` use) as virtual modules, with `entrypoint` inferred from the Vitest project's own root (via `configResolved`) when not given explicitly, so each cookbook's `vitest.config.ts` needs no `entrypoint` override when run as part of a multi-project Vitest run.
|
|
22
|
+
- A `/test` entry-point exporting `test`/`render`, pre-seeded from the resolved manifest/config/configure once `appTestVitePlugin` is registered — no per-test `env`/`configure` wiring — plus `mergeEnvConfig` for overriding one endpoint's URL (or an `environment` value) on `appEnv` without dropping the rest of the app's `AppConfig`.
|
|
23
|
+
- A `/config` entry-point exporting `defineProject`: a drop-in for Vitest's own `defineProject`, pre-wired with `appTestVitePlugin` and the `@vitest/browser-playwright`/`chromium` browser provider, so a consuming app's own `vitest.config.ts` needs no browser-provider boilerplate:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { defineProject } from '@equinor/fusion-framework-vitest-plugin-react-app/config';
|
|
27
|
+
import { name, version } from './package.json' with { type: 'json' };
|
|
28
|
+
|
|
29
|
+
export default defineProject({ test: { name: `${name}@${version}` } });
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
`defineProject` defaults `test.browser.viewport` to `1024x768` instead of Vitest's own mobile-sized default, matching the low, fixed resolution most Fusion apps see in production through Citrix (pass `test.browser.viewport` to use a different size), sets `server.warmup.clientFiles: ['src/**/*.{ts,tsx}']` so lazily/code-split-imported source (e.g. route components reached only through dynamic `import()`) is transformed up front instead of forcing a page reload mid-test, and excludes `.d.ts` files from the default `server.warmup.clientFiles`/`optimizeDeps.entries` globs so a CJS-style declaration file (e.g. one using `export =`) does not fail the Vite warmup scan. `override` is deep-merged onto the default config via Vite's own `mergeConfig` (a plain object), or applied to the default config outright (a function receiving it) — for changes `mergeConfig` can't express, such as swapping `test.browser.provider` for a different `@vitest/browser-*` provider.
|
|
33
|
+
- The mocked framework enables the feature-flag mock by default (no flags enabled) when `@equinor/fusion-framework-module-feature-flag` is installed, so `useFeature` needs no `localStorage`/URL seeding in tests, and defaults navigation to in-memory history rather than browser history (which leaked URL/history state between tests) — `configureFusion`/`enableNavigation` can still opt back into browser history for a test that specifically needs it.
|
|
34
|
+
|
|
35
|
+
`@vitest/browser-playwright` and `playwright` are peer dependencies of the package. Package documentation provides task-focused guides for setup, configuration, advanced fixtures, module mocks, and troubleshooting so npm, GitHub, and retrieval clients use the same canonical source as the VuePress site.
|
|
123
36
|
|
|
124
37
|
### Patch Changes
|
|
125
38
|
|
|
126
|
-
-
|
|
127
|
-
|
|
128
|
-
Packages without their own changes are bumped only to receive a `-next.N` version and the `next` dist-tag on npm. Install with:
|
|
129
|
-
|
|
130
|
-
```bash
|
|
131
|
-
pnpm add @equinor/fusion-framework-react-app@next
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
- 2836e0b: Fix `defineProject` not pre-transforming lazily/code-split-imported source (e.g. route
|
|
135
|
-
components reached only through dynamic `import()`), which could force Vite to reload the
|
|
136
|
-
page mid-test and fail the in-flight test file's import.
|
|
137
|
-
|
|
138
|
-
`defineProject`'s Vite config now sets `server.warmup.clientFiles: ['src/**/*.{ts,tsx}']`, so
|
|
139
|
-
all source under `src/` is transformed up front instead of on first request.
|
|
140
|
-
|
|
141
|
-
- 2836e0b: Document `test.override(...)` for overriding a fixture (`configure`, `fusion`, etc.) within a
|
|
39
|
+
- f663b46: Document `test.override(...)` for overriding a fixture (`configure`, `fusion`, etc.) within a
|
|
142
40
|
single test file or `describe` block, alongside the existing `test.extend(...)` guide, in the
|
|
143
41
|
package's "Advanced usage" doc (`docs/advanced.md`).
|
|
144
|
-
-
|
|
42
|
+
- f663b46: Add a "Migrate an existing app" guide (`docs/migrating-an-existing-app.md`) covering how to
|
|
145
43
|
move a suite from `@testing-library/react`/jsdom/happy-dom onto this package: installing
|
|
146
44
|
Browser Mode, replacing hand-rolled `vi.mock`s of Fusion hooks with each module's `enable*Mock`
|
|
147
45
|
entry point, porting a hand-written mock HTTP server to `createRouterMiddleware`, composing a
|
|
148
46
|
router fixture with a domain-state fixture in one file, and updating renders/assertions to the
|
|
149
47
|
async `vitest-browser-react` API. Linked from the package README and from
|
|
150
48
|
`docs/overview.md` and `testing-choosing-a-layer.md`.
|
|
151
|
-
-
|
|
49
|
+
- f663b46: Add a "Why Browser Mode is the default" guide (`docs/why-browser-mode.md`) explaining
|
|
152
50
|
the rationale for defaulting to real Chromium over DOM emulation (the documented React 19 peer
|
|
153
51
|
dependency crash in the previous renderer, plus the framework's real-module testing philosophy),
|
|
154
52
|
the actual performance tradeoff (a real browser is slower, not faster — this was a fidelity
|
|
@@ -156,28 +54,28 @@
|
|
|
156
54
|
composing `mockFramework`/`mockAppModules`/`FrameworkProvider`/`ModuleProvider` directly with a
|
|
157
55
|
different render function (e.g. `@testing-library/react` on `happy-dom`). Linked from the
|
|
158
56
|
package README and `docs/overview.md`.
|
|
159
|
-
- Updated dependencies [
|
|
160
|
-
- Updated dependencies [
|
|
161
|
-
- Updated dependencies [
|
|
162
|
-
- Updated dependencies [
|
|
163
|
-
- Updated dependencies [
|
|
164
|
-
- Updated dependencies [
|
|
165
|
-
- Updated dependencies [
|
|
166
|
-
- Updated dependencies [
|
|
167
|
-
- Updated dependencies [
|
|
168
|
-
- Updated dependencies [
|
|
169
|
-
- Updated dependencies [
|
|
170
|
-
- Updated dependencies [
|
|
171
|
-
- Updated dependencies [
|
|
172
|
-
- Updated dependencies [
|
|
173
|
-
- Updated dependencies [
|
|
174
|
-
-
|
|
175
|
-
-
|
|
176
|
-
- @equinor/fusion-framework@8.1.0
|
|
177
|
-
- @equinor/fusion-framework-
|
|
178
|
-
- @equinor/fusion-
|
|
179
|
-
- @equinor/fusion-framework-module@
|
|
180
|
-
- @equinor/fusion-framework-module
|
|
181
|
-
- @equinor/fusion-framework-
|
|
182
|
-
- @equinor/fusion-framework-react-module@4.0.3
|
|
183
|
-
- @equinor/fusion-
|
|
57
|
+
- Updated dependencies [f663b46]
|
|
58
|
+
- Updated dependencies [f663b46]
|
|
59
|
+
- Updated dependencies [f663b46]
|
|
60
|
+
- Updated dependencies [f663b46]
|
|
61
|
+
- Updated dependencies [f663b46]
|
|
62
|
+
- Updated dependencies [f663b46]
|
|
63
|
+
- Updated dependencies [f663b46]
|
|
64
|
+
- Updated dependencies [f663b46]
|
|
65
|
+
- Updated dependencies [f663b46]
|
|
66
|
+
- Updated dependencies [f663b46]
|
|
67
|
+
- Updated dependencies [f663b46]
|
|
68
|
+
- Updated dependencies [f663b46]
|
|
69
|
+
- Updated dependencies [f663b46]
|
|
70
|
+
- Updated dependencies [f663b46]
|
|
71
|
+
- Updated dependencies [f663b46]
|
|
72
|
+
- @equinor/fusion-framework-app@13.1.0
|
|
73
|
+
- @equinor/fusion-framework-cli@15.3.0
|
|
74
|
+
- @equinor/fusion-framework@8.1.0
|
|
75
|
+
- @equinor/fusion-framework-module-feature-flag@2.1.0
|
|
76
|
+
- @equinor/fusion-imports@2.0.3
|
|
77
|
+
- @equinor/fusion-framework-module-app@8.1.0
|
|
78
|
+
- @equinor/fusion-framework-module@6.1.3
|
|
79
|
+
- @equinor/fusion-framework-module-navigation@7.0.9
|
|
80
|
+
- @equinor/fusion-framework-react-module@4.0.3
|
|
81
|
+
- @equinor/fusion-framework-react@9.0.0
|
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC"}
|