@equinor/fusion-framework-vitest-plugin-react-app 0.2.0-next.0 → 0.2.0-next.2
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 +14 -0
- package/dist/esm/define-project.js +6 -1
- package/dist/esm/define-project.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/define-project.d.ts +3 -1
- package/dist/types/version.d.ts +1 -1
- package/docs/configuration.md +4 -1
- package/docs/why-browser-mode.md +22 -7
- package/package.json +4 -4
- package/src/define-project.ts +6 -1
- package/src/version.ts +1 -1
|
@@ -15,7 +15,9 @@ export type AppTestConfigOverride = Partial<UserWorkspaceConfig> | ((config: Use
|
|
|
15
15
|
* Drop-in replacement for Vitest's own `defineProject` — same `export default`, just pre-wired.
|
|
16
16
|
* Playwright/`chromium` is only the *default* — pass `override` to change or replace anything
|
|
17
17
|
* (e.g. `test.name`, or swap `test.browser.provider` for a different `@vitest/browser-*`
|
|
18
|
-
* provider) without hand-rolling `appTestVitePlugin`'s own wiring.
|
|
18
|
+
* provider) without hand-rolling `appTestVitePlugin`'s own wiring. The default `1024x768`
|
|
19
|
+
* viewport matches a typical low-resolution Citrix session rather than Vitest's own
|
|
20
|
+
* mobile-sized default; pass `test.browser.viewport` to use a different size.
|
|
19
21
|
*
|
|
20
22
|
* @example
|
|
21
23
|
* ```ts
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.2.0-next.
|
|
1
|
+
export declare const version = "0.2.0-next.2";
|
package/docs/configuration.md
CHANGED
|
@@ -22,6 +22,8 @@ The default project registers `appTestVitePlugin()` and configures:
|
|
|
22
22
|
- Vitest Browser Mode enabled
|
|
23
23
|
- the Playwright provider with one Chromium instance
|
|
24
24
|
- headless browser execution
|
|
25
|
+
- a `1024x768` default viewport, matching a typical low-resolution Citrix session rather than
|
|
26
|
+
Vitest's own mobile-sized default
|
|
25
27
|
- Vite warmup for `src/**/*.{ts,tsx}` to discover lazy imports before tests run
|
|
26
28
|
|
|
27
29
|
## Merge ordinary Vitest options
|
|
@@ -35,7 +37,8 @@ import { name, version } from './package.json' with { type: 'json' };
|
|
|
35
37
|
export default defineProject({
|
|
36
38
|
test: {
|
|
37
39
|
name: `${name}@${version}`,
|
|
38
|
-
|
|
40
|
+
// opt into a wider viewport for an app that only needs to support desktop
|
|
41
|
+
browser: { viewport: { width: 1920, height: 1080 } },
|
|
39
42
|
},
|
|
40
43
|
});
|
|
41
44
|
```
|
package/docs/why-browser-mode.md
CHANGED
|
@@ -25,13 +25,22 @@ they do not need browser behavior.
|
|
|
25
25
|
[Module mocks](module-mocks.md), while the actual module configuration, lifecycle, providers,
|
|
26
26
|
and rendering behavior still run.
|
|
27
27
|
- **Browser fidelity:** Chromium provides real layout, `ResizeObserver`, custom elements, and
|
|
28
|
-
Shadow DOM
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
A
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
component
|
|
28
|
+
Shadow DOM — behavior `happy-dom` and `jsdom` only approximate.
|
|
29
|
+
|
|
30
|
+
> [!WARNING]
|
|
31
|
+
> A DOM-emulation gap is usually patched one of two ways: a polyfill standing in for the missing
|
|
32
|
+
> browser API, or a component replacement that avoids exercising it at all. Both are test-only
|
|
33
|
+
> code with no equivalent in production, and both defeat the point of the test: a polyfill can
|
|
34
|
+
> drift from real browser behavior unnoticed, and a mocked component only proves the *mock*
|
|
35
|
+
> renders correctly, never the real one. A passing test built on either can still fail — or
|
|
36
|
+
> silently lie — against the real component. Treat every DOM-emulation workaround as debt to
|
|
37
|
+
> remove, not a pattern to reach for.
|
|
38
|
+
|
|
39
|
+
A real browser does not eliminate every workaround: AG Grid license messages and Lit dev-mode
|
|
40
|
+
warnings are console noise from real Chromium runs, not DOM-emulation gaps, and suppressing them
|
|
41
|
+
carries none of the risk above (see [Module mocks](module-mocks.md) for the supported way to
|
|
42
|
+
seed module state instead of replacing a component). Remove a DOM-emulation-only workaround only
|
|
43
|
+
after confirming the affected test still passes against the real component in Browser Mode.
|
|
35
44
|
|
|
36
45
|
## Choose a different runtime
|
|
37
46
|
|
|
@@ -58,6 +67,12 @@ See [Configuration](configuration.md) for the complete `defineProject` behavior.
|
|
|
58
67
|
|
|
59
68
|
### Use happy-dom or jsdom
|
|
60
69
|
|
|
70
|
+
> [!CAUTION]
|
|
71
|
+
> Rendering with `happy-dom` or `jsdom` reintroduces the DOM-emulation tradeoff above: any gap
|
|
72
|
+
> between the emulation and a real browser has to be closed with a polyfill or a component
|
|
73
|
+
> replacement, not fixed. Only take this path for a component or hook that provably does not
|
|
74
|
+
> need browser fidelity — otherwise stay in Browser Mode.
|
|
75
|
+
|
|
61
76
|
The Fusion module setup does not depend on Browser Mode. Build the same provider tree and pass it
|
|
62
77
|
to another renderer. The example below uses `@testing-library/react` on `happy-dom`:
|
|
63
78
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/fusion-framework-vitest-plugin-react-app",
|
|
3
|
-
"version": "0.2.0-next.
|
|
3
|
+
"version": "0.2.0-next.2",
|
|
4
4
|
"description": "Vite plugin resolving an application's manifest, config, and module-configurator as virtual modules for testing.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -48,13 +48,13 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@equinor/fusion-framework": "8.1.0-next.0",
|
|
51
|
+
"@equinor/fusion-framework-module": "6.1.3-next.0",
|
|
51
52
|
"@equinor/fusion-framework-app": "14.0.0-next.0",
|
|
53
|
+
"@equinor/fusion-framework-cli": "15.2.8-next.1",
|
|
52
54
|
"@equinor/fusion-framework-module-app": "8.1.0-next.0",
|
|
53
55
|
"@equinor/fusion-framework-react": "9.0.0-next.0",
|
|
54
|
-
"@equinor/fusion-framework-react-module": "4.0.3-next.0",
|
|
55
56
|
"@equinor/fusion-imports": "2.0.3-next.0",
|
|
56
|
-
"@equinor/fusion-framework-
|
|
57
|
-
"@equinor/fusion-framework-module": "6.1.3-next.0"
|
|
57
|
+
"@equinor/fusion-framework-react-module": "4.0.3-next.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/react": "^19.2.7",
|
package/src/define-project.ts
CHANGED
|
@@ -26,7 +26,9 @@ export type AppTestConfigOverride =
|
|
|
26
26
|
* Drop-in replacement for Vitest's own `defineProject` — same `export default`, just pre-wired.
|
|
27
27
|
* Playwright/`chromium` is only the *default* — pass `override` to change or replace anything
|
|
28
28
|
* (e.g. `test.name`, or swap `test.browser.provider` for a different `@vitest/browser-*`
|
|
29
|
-
* provider) without hand-rolling `appTestVitePlugin`'s own wiring.
|
|
29
|
+
* provider) without hand-rolling `appTestVitePlugin`'s own wiring. The default `1024x768`
|
|
30
|
+
* viewport matches a typical low-resolution Citrix session rather than Vitest's own
|
|
31
|
+
* mobile-sized default; pass `test.browser.viewport` to use a different size.
|
|
30
32
|
*
|
|
31
33
|
* @example
|
|
32
34
|
* ```ts
|
|
@@ -57,6 +59,9 @@ export const defineProject = (override?: AppTestConfigOverride): UserWorkspaceCo
|
|
|
57
59
|
enabled: true,
|
|
58
60
|
provider: playwright(),
|
|
59
61
|
headless: true,
|
|
62
|
+
// most users run the app through Citrix at a low, fixed resolution rather than a
|
|
63
|
+
// resizable desktop window — default to that instead of Vitest's own mobile-sized viewport
|
|
64
|
+
viewport: { width: 1024, height: 768 },
|
|
60
65
|
instances: [{ browser: 'chromium' }],
|
|
61
66
|
},
|
|
62
67
|
},
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '0.2.0-next.
|
|
2
|
+
export const version = '0.2.0-next.2';
|