@forgebook/testing 0.1.0 → 0.1.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 +134 -4
- package/dist/bin/forgebook-heights/measureHeights.d.ts +1 -1
- package/dist/bin/forgebook-heights/measureHeights.js +1 -1
- package/dist/bin/forgebook-shot/storyShot.js +1 -1
- package/dist/src/browserTests.js +5 -5
- package/dist/src/browserTests.js.map +1 -1
- package/dist/src/overlays.d.ts +2 -2
- package/dist/src/playwrightConfig.d.ts +12 -0
- package/dist/src/playwrightConfig.d.ts.map +1 -1
- package/dist/src/playwrightConfig.js +20 -3
- package/dist/src/playwrightConfig.js.map +1 -1
- package/dist/src/serverTests.d.ts +1 -1
- package/dist/src/serverTests.js +2 -2
- package/dist/src/serverTests.js.map +1 -1
- package/dist/src/testViteConfig.d.ts +1 -1
- package/dist/src/testViteConfig.js +1 -1
- package/dist/src/visualBrowser.js +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -11,13 +11,144 @@ tests:
|
|
|
11
11
|
- **on the server** (Vitest), each story rendered to a string, so no component reads `window` or `document` while it
|
|
12
12
|
renders, and its controls checked against its args.
|
|
13
13
|
|
|
14
|
-
**Requirements:** `forgebook` · Vite 8 · `@playwright/test` 1.64+ · Vitest 5 ·
|
|
15
|
-
[MIT licence](https://github.com/
|
|
14
|
+
**Requirements:** `forgebook` · Vite 8 · `@playwright/test` 1.64+ · Vitest 5 · Docker for the visual tests ·
|
|
15
|
+
[MIT licence](https://github.com/ensiria/forgebook/blob/develop/packages/testing/LICENSE)
|
|
16
16
|
|
|
17
17
|
```sh
|
|
18
18
|
npm install --save-dev @forgebook/testing @playwright/test vitest
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
+
## Setting up the tests
|
|
22
|
+
|
|
23
|
+
The tests run on the package's own **story source** (the `StorySource` its catalogue lists), in a folder of their
|
|
24
|
+
own. The example below is a package whose stories are `src/*.stories.tsx` and whose source is `stories/index.ts`:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
// stories/index.ts
|
|
28
|
+
/// <reference types="@forgebook/story-format/client" />
|
|
29
|
+
import type { StorySource } from "@forgebook/story-format/source";
|
|
30
|
+
|
|
31
|
+
import files from "../src/*.stories.tsx?forgebook-files";
|
|
32
|
+
|
|
33
|
+
export const source: StorySource = {
|
|
34
|
+
id: "acme-ui",
|
|
35
|
+
name: "Acme UI",
|
|
36
|
+
files: [files],
|
|
37
|
+
sheets: { required: [], theme: [], restyled: [] }
|
|
38
|
+
};
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### In the browser
|
|
42
|
+
|
|
43
|
+
Six files in `test/stories/`. Where the stories are, with the same patterns as the source:
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
// test/stories/storyFiles.ts
|
|
47
|
+
import { join } from "node:path";
|
|
48
|
+
|
|
49
|
+
import type { StoryFilesOptions } from "@forgebook/testing/story-files";
|
|
50
|
+
|
|
51
|
+
export const STORY_FILES: StoryFilesOptions = {
|
|
52
|
+
sourceId: "acme-ui",
|
|
53
|
+
name: "Acme UI",
|
|
54
|
+
root: join(import.meta.dirname, "..", "..", "stories"),
|
|
55
|
+
patterns: ["../src/*.stories.tsx"]
|
|
56
|
+
};
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The folder and the ports, then the Playwright configuration and the spec:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
// test/stories/testServer.ts
|
|
63
|
+
import type { StoryTestServer } from "@forgebook/testing/playwright";
|
|
64
|
+
|
|
65
|
+
export const STORY_SERVER: StoryTestServer = { dir: import.meta.dirname, port: 41831, browserPort: 41832 };
|
|
66
|
+
|
|
67
|
+
// test/stories/playwright.config.ts
|
|
68
|
+
import { storyTestConfig } from "@forgebook/testing/playwright";
|
|
69
|
+
|
|
70
|
+
import { STORY_SERVER } from "./testServer";
|
|
71
|
+
|
|
72
|
+
export default storyTestConfig(STORY_SERVER);
|
|
73
|
+
|
|
74
|
+
// test/stories/stories.spec.ts
|
|
75
|
+
import { storyBrowserTests } from "@forgebook/testing/browser";
|
|
76
|
+
|
|
77
|
+
import { STORY_FILES } from "./storyFiles";
|
|
78
|
+
|
|
79
|
+
storyBrowserTests(STORY_FILES);
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The frame page the tests open, and the Vite configuration that serves it:
|
|
83
|
+
|
|
84
|
+
```html
|
|
85
|
+
<!-- test/stories/frame.html -->
|
|
86
|
+
<!doctype html>
|
|
87
|
+
<html lang="en">
|
|
88
|
+
<head><meta charset="utf-8" /><title>Stories</title></head>
|
|
89
|
+
<body><div id="root"></div><script type="module" src="./frame.tsx"></script></body>
|
|
90
|
+
</html>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
// test/stories/frame.tsx
|
|
95
|
+
import "@forgebook/testing/fonts.css";
|
|
96
|
+
import { mountFrame } from "@forgebook/react/frame";
|
|
97
|
+
|
|
98
|
+
import { source } from "../../stories/index";
|
|
99
|
+
|
|
100
|
+
const root = document.getElementById("root");
|
|
101
|
+
if (root !== null) void mountFrame(root, { sources: [source] });
|
|
102
|
+
|
|
103
|
+
// test/stories/vite.config.ts
|
|
104
|
+
import { react } from "@forgebook/react/vite";
|
|
105
|
+
import { storyTestViteConfig } from "@forgebook/testing/vite";
|
|
106
|
+
|
|
107
|
+
export default storyTestViteConfig(import.meta.dirname, react());
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Then `npx playwright install chromium` once, and `playwright test -c test/stories/playwright.config.ts` starts the
|
|
111
|
+
frame page and runs one test per story and variant (light, dark, both with more contrast, a narrow width, and the
|
|
112
|
+
structure view), starting Vite through the package manager that runs them (`vite` in `testServer.ts` names
|
|
113
|
+
another command). A story that breaks a rule fails all its variants; `storyBrowserTests` also takes `check`, a rule of
|
|
114
|
+
the package's own run on every frame.
|
|
115
|
+
|
|
116
|
+
### On the server
|
|
117
|
+
|
|
118
|
+
One test file and a Vitest configuration with the catalogue's plugin, which reads the source's
|
|
119
|
+
`?forgebook-files` imports:
|
|
120
|
+
|
|
121
|
+
```tsx
|
|
122
|
+
// test/stories/stories.server.test.tsx
|
|
123
|
+
import { reactRenderer } from "@forgebook/react/renderer";
|
|
124
|
+
import { storyServerTests } from "@forgebook/testing/server";
|
|
125
|
+
|
|
126
|
+
import { source } from "../../stories/index";
|
|
127
|
+
|
|
128
|
+
storyServerTests(source, { renderer: reactRenderer });
|
|
129
|
+
|
|
130
|
+
// vitest.config.ts
|
|
131
|
+
import { react } from "@forgebook/react/vite";
|
|
132
|
+
import { forgebookPlugin } from "forgebook/vite";
|
|
133
|
+
import { defineConfig } from "vitest/config";
|
|
134
|
+
|
|
135
|
+
export default defineConfig({
|
|
136
|
+
plugins: [forgebookPlugin({ framework: react() })],
|
|
137
|
+
test: { include: ["test/**/*.test.tsx"] }
|
|
138
|
+
});
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
`storyServerTests` also takes `wrap`: a second pass with every story inside a decorator (a provider with a partial
|
|
142
|
+
translation catalogue), its HTML checked.
|
|
143
|
+
|
|
144
|
+
### Limits today
|
|
145
|
+
|
|
146
|
+
- The visual tests (`visual.spec.ts`, `visualTestConfig`, `startVisualBrowser`) compare the frames with reference
|
|
147
|
+
images in the Playwright container, so they need Docker; this guide does not cover them yet, their modules' TSDoc
|
|
148
|
+
does.
|
|
149
|
+
|
|
150
|
+
## Imports and commands
|
|
151
|
+
|
|
21
152
|
| Import or command | What it is |
|
|
22
153
|
|---|---|
|
|
23
154
|
| `@forgebook/testing/browser` | The browser and visual tests of every story |
|
|
@@ -26,5 +157,4 @@ npm install --save-dev @forgebook/testing @playwright/test vitest
|
|
|
26
157
|
| `forgebook-heights` | Measures every story's height at a few widths, for the catalogue's loading boxes |
|
|
27
158
|
| `forgebook-shot` | Opens one story of a running catalogue and reports it with a picture |
|
|
28
159
|
|
|
29
|
-
|
|
30
|
-
[Forgebook's README](https://github.com/Ensiria/forgebook/blob/develop/packages/forgebook/README.md).
|
|
160
|
+
More: [Forgebook's README](https://github.com/ensiria/forgebook/blob/develop/packages/forgebook/README.md).
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* opens every story's frame and measures it at each width.
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
|
-
* The frame page is the one the catalogue's stage opens
|
|
6
|
+
* The frame page is the one the catalogue's stage opens, and its height is read as the frame reports it to
|
|
7
7
|
* the shell (the body's own height), so a measured height is the one the stage would get. A story loads once at the
|
|
8
8
|
* first width and is then resized through the others: a reload per width would multiply the run by them. `--serve`
|
|
9
9
|
* serves a built catalogue with Vite's preview server, where a frame loads in one request per chunk instead of the
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* opens every story's frame and measures it at each width.
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
|
-
* The frame page is the one the catalogue's stage opens
|
|
6
|
+
* The frame page is the one the catalogue's stage opens, and its height is read as the frame reports it to
|
|
7
7
|
* the shell (the body's own height), so a measured height is the one the stage would get. A story loads once at the
|
|
8
8
|
* first width and is then resized through the others: a reload per width would multiply the run by them. `--serve`
|
|
9
9
|
* serves a built catalogue with Vite's preview server, where a frame loads in one request per chunk instead of the
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* waits for its story and reports.
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
|
-
* The frame page is the address the catalogue and the generated tests open
|
|
6
|
+
* The frame page is the address the catalogue and the generated tests open: what an agent sees is what a
|
|
7
7
|
* person sees in the stage. `shotAddress` is pure; `takeShot` drives Chromium through Playwright.
|
|
8
8
|
*
|
|
9
9
|
* @module
|
package/dist/src/browserTests.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* One Playwright test per story and variant, on the catalogue's frame pages: the address the catalogue shows is the
|
|
3
|
-
* address the tests open
|
|
3
|
+
* address the tests open.
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
6
|
* Each test opens the frame for a story in a variant (the theme, the contrast, the style sheets), waits for the
|
|
7
|
-
* frame to say the story is shown (`data-forgebook-status`), its story clock held at its start
|
|
7
|
+
* frame to say the story is shown (`data-forgebook-status`), its story clock held at its start, and fails on an error in the console or the page, or on
|
|
8
8
|
* an axe violation of WCAG 2.2 A and AA, on an element that spills out of its parent (`spills.ts`: what overlaps a
|
|
9
9
|
* neighbour when the story is narrower than it was drawn for), on an overlay its play leaves open past the frame the
|
|
10
|
-
* catalogue would give it (`overlays.ts`: the story then declares `parameters.height
|
|
10
|
+
* catalogue would give it (`overlays.ts`: the story then declares `parameters.height`), or on the source's own
|
|
11
11
|
* `check`. The variants include a
|
|
12
12
|
* narrow frame, as wide as the catalogue's stage beside the props panel. With `screenshot` it compares the frame with its reference image instead,
|
|
13
13
|
* for the visual tests, which run in the Playwright container so fonts and rendering are the same everywhere.
|
|
@@ -100,8 +100,8 @@ export const storyBrowserTests = (options) => {
|
|
|
100
100
|
});
|
|
101
101
|
if (variant.width !== undefined)
|
|
102
102
|
await page.setViewportSize({ width: variant.width, height: 800 });
|
|
103
|
-
// a Live story is checked and pictured at its start: its clock held, so its image never changes
|
|
104
|
-
// always on its page's own colour, whatever a variant names: a backdrop is for looking
|
|
103
|
+
// a Live story is checked and pictured at its start: its clock held, so its image never changes;
|
|
104
|
+
// always on its page's own colour, whatever a variant names: a backdrop is for looking
|
|
105
105
|
const view = {
|
|
106
106
|
...defaults,
|
|
107
107
|
...variant.view,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browserTests.js","sourceRoot":"","sources":["../../src/browserTests.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAa,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAuB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,g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|
1
1
|
/**
|
|
2
2
|
* The overlays a story leaves open past its frame: what a frame as tall as the story would cut or push to the other
|
|
3
|
-
* side, so the story needs `parameters.height
|
|
3
|
+
* side, so the story needs `parameters.height`.
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
6
|
* The catalogue sizes a story's frame to its document's body, and the window of the frame is the overlays' window;
|
|
7
7
|
* the tests open the frame in a window taller than that, where an overlay opened near the story's foot still fits. So
|
|
8
8
|
* after the play an overlay is measured against the frame the shell would give it: the body's height, or the height
|
|
9
9
|
* the story declares when that is more. Without knowing
|
|
10
|
-
* the library
|
|
10
|
+
* the library, an overlay is any element with `position: fixed` that shows (a box, not hidden, not
|
|
11
11
|
* transparent) and whose box ends more than a pixel below the body. A fixed element placed against the window rather
|
|
12
12
|
* than against what opened it (a full-window layer, a toast region pinned to the window's foot, a drawer) is told
|
|
13
13
|
* apart by covering the window's whole height, or by growing the window: it moves or grows with it, an anchored
|
|
@@ -9,7 +9,19 @@ export type StoryTestServer = {
|
|
|
9
9
|
readonly browserPort: number;
|
|
10
10
|
/** How many tests run at once; every core when left out or not a positive number. */
|
|
11
11
|
readonly workers?: number;
|
|
12
|
+
/**
|
|
13
|
+
* The command that runs Vite (`node ./node_modules/vite/bin/vite.js`); by default the package manager that runs
|
|
14
|
+
* the tests runs it (`frameServerCommand`).
|
|
15
|
+
*/
|
|
16
|
+
readonly vite?: string;
|
|
12
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* The command that runs Vite, through the package manager that runs the tests: the one its user agent names
|
|
20
|
+
* (`npm_config_user_agent`, which every package manager sets for the scripts it runs), npx when none does.
|
|
21
|
+
*
|
|
22
|
+
* @param userAgent - the package manager's user agent (`pnpm/10.19.0 npm/? node/v24.15.0 darwin arm64`), if any.
|
|
23
|
+
*/
|
|
24
|
+
export declare const frameServerCommand: (userAgent: string | undefined) => string;
|
|
13
25
|
/**
|
|
14
26
|
* The browser tests' configuration: `stories.spec.ts` in the host's Chromium.
|
|
15
27
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playwrightConfig.d.ts","sourceRoot":"","sources":["../../src/playwrightConfig.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,iEAAiE;AACjE,MAAM,MAAM,eAAe,GAAG;IAC5B,mGAAmG;IACnG,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,yEAAyE;IACzE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,qFAAqF;IACrF,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"playwrightConfig.d.ts","sourceRoot":"","sources":["../../src/playwrightConfig.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,iEAAiE;AACjE,MAAM,MAAM,eAAe,GAAG;IAC5B,mGAAmG;IACnG,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,yEAAyE;IACzE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,qFAAqF;IACrF,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAUF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,cAAe,MAAM,GAAG,SAAS,KAAG,MAGlE,CAAC;AAaF;;;;GAIG;AACH,eAAO,MAAM,eAAe,WAAY,eAAe,KAAG,oBAQxD,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,WAAY,eAAe,KAAG,oBAkB1D,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* visual tests in the Playwright container's browser, both on the package's own test instance of the frame page.
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
|
-
* Published (`forgebook/testing/playwright
|
|
6
|
+
* Published (`forgebook/testing/playwright`). The package keeps a folder with its specs
|
|
7
7
|
* (`stories.spec.ts`, `visual.spec.ts`), its frame page (`frame.html`), the Vite config that serves it
|
|
8
8
|
* (`vite.config.ts`, from `storyTestViteConfig`) and the visual tests' global setup (`visualBrowser.ts`, from
|
|
9
9
|
* `startVisualBrowser`); each package names its own ports, so two packages' tests run side by side. In CI the visual
|
|
@@ -12,11 +12,28 @@
|
|
|
12
12
|
* @module
|
|
13
13
|
*/
|
|
14
14
|
import { availableParallelism } from "node:os";
|
|
15
|
+
/** The command each package manager runs a dependency's binary with, by the name its user agent starts with. */
|
|
16
|
+
const RUNNERS = {
|
|
17
|
+
pnpm: "pnpm exec vite",
|
|
18
|
+
yarn: "yarn vite",
|
|
19
|
+
bun: "bunx vite",
|
|
20
|
+
npm: "npx vite"
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The command that runs Vite, through the package manager that runs the tests: the one its user agent names
|
|
24
|
+
* (`npm_config_user_agent`, which every package manager sets for the scripts it runs), npx when none does.
|
|
25
|
+
*
|
|
26
|
+
* @param userAgent - the package manager's user agent (`pnpm/10.19.0 npm/? node/v24.15.0 darwin arm64`), if any.
|
|
27
|
+
*/
|
|
28
|
+
export const frameServerCommand = (userAgent) => {
|
|
29
|
+
const manager = userAgent?.split("/")[0] ?? "npm";
|
|
30
|
+
return RUNNERS[manager] ?? "npx vite";
|
|
31
|
+
};
|
|
15
32
|
/** The workers to use. */
|
|
16
33
|
const workersOf = ({ workers }) => workers !== undefined && workers > 0 ? workers : availableParallelism();
|
|
17
34
|
/** The test instance of the frame page, started by Playwright and stopped after the run. */
|
|
18
|
-
const webServer = ({ dir, port }) => ({
|
|
19
|
-
command:
|
|
35
|
+
const webServer = ({ dir, port, vite }) => ({
|
|
36
|
+
command: `${vite ?? frameServerCommand(process.env["npm_config_user_agent"])} --config ${dir}/vite.config.ts --host 127.0.0.1 --port ${port} --strictPort`,
|
|
20
37
|
url: `http://127.0.0.1:${port}/frame.html`,
|
|
21
38
|
reuseExistingServer: false
|
|
22
39
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playwrightConfig.js","sourceRoot":"","sources":["../../src/playwrightConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"playwrightConfig.js","sourceRoot":"","sources":["../../src/playwrightConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAqB/C,gHAAgH;AAChH,MAAM,OAAO,GAAqC;IAChD,IAAI,EAAE,gBAAgB;IACtB,IAAI,EAAE,WAAW;IACjB,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,UAAU;CAChB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,SAA6B,EAAU,EAAE;IAC1E,MAAM,OAAO,GAAG,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC;IAClD,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,UAAU,CAAC;AACxC,CAAC,CAAC;AAEF,0BAA0B;AAC1B,MAAM,SAAS,GAAG,CAAC,EAAE,OAAO,EAAmB,EAAU,EAAE,CACzD,OAAO,KAAK,SAAS,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,oBAAoB,EAAE,CAAC;AAE1E,4FAA4F;AAC5F,MAAM,SAAS,GAAG,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAmB,EAAkD,EAAE,CAAC,CAAC;IAC3G,OAAO,EAA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AQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE;YACtC,OAAO,EAAE,UAAU,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,sBAAsB,IAAI,MAAM,CAAC,IAAI,GAAG;YACzF,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,EAAE,UAAU,EAAE,kBAAkB,MAAM,CAAC,WAAW,GAAG,EAAE,EAAE,CAAC;SACtG;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* One Vitest test per story: the framework renders it to a string without errors (`renderToString` of its renderer),
|
|
3
|
-
* so no component reads `window` or `document` while rendering
|
|
3
|
+
* so no component reads `window` or `document` while rendering, and its controls tell the truth
|
|
4
4
|
* (`storyControlsProblem`).
|
|
5
5
|
*
|
|
6
6
|
* @remarks
|
package/dist/src/serverTests.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* One Vitest test per story: the framework renders it to a string without errors (`renderToString` of its renderer),
|
|
3
|
-
* so no component reads `window` or `document` while rendering
|
|
3
|
+
* so no component reads `window` or `document` while rendering, and its controls tell the truth
|
|
4
4
|
* (`storyControlsProblem`).
|
|
5
5
|
*
|
|
6
6
|
* @remarks
|
|
@@ -49,7 +49,7 @@ export const storyServerTests = (source, options) => {
|
|
|
49
49
|
// the stories' own texts: what the catalogue shows when no language is chosen
|
|
50
50
|
const texts = source.texts?.[BASE_LANGUAGE] ?? {};
|
|
51
51
|
const args = withStoryTexts(loaded.args, storyTextOf(texts));
|
|
52
|
-
// a Live story renders at its start, as the frame's tests picture it
|
|
52
|
+
// a Live story renders at its start, as the frame's tests picture it
|
|
53
53
|
const clock = heldFrameClock(loaded.clockStart ?? 0);
|
|
54
54
|
// the loaders and set-ups run as in the frame, so a story drawn from what they load renders here too
|
|
55
55
|
const identity = { id: story.id, name: story.name, title: component.title };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverTests.js","sourceRoot":"","sources":["../../src/serverTests.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAwB,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACtG,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAyB1D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAmB,EAAE,OAAgC,EAAQ,EAAE;IAC9F,MAAM,MAAM,GAA+B;QACzC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE;QACvC,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;KACtD,CAAC;IACF,MAAM,OAAO,GAAG,cAAc,CAAC,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC;IAC1E,SAAS,CAAC,KAAK,IAAI,EAAE;QACnB,MAAM,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;QAC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AM,IAAI,KAAK,CAAC,iBAAiB,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;oBAC3E,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,IAAI,EAAE,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;oBACzD,IAAI,OAAO,MAAM,KAAK,QAAQ;wBAAE,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;oBACxD,MAAM,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;gBACvD,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* container's browser asks for.
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
|
-
* Published (`forgebook/testing/vite
|
|
6
|
+
* Published (`forgebook/testing/vite`). The package's `vite.config.ts` beside its specs exports it.
|
|
7
7
|
* Vite serves files up to its workspace root (the monorepo's, or the package's alone), which covers the package's
|
|
8
8
|
* sources, the libraries it builds on and this kit's fonts.
|
|
9
9
|
*
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* container's browser asks for.
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
|
-
* Published (`forgebook/testing/vite
|
|
6
|
+
* Published (`forgebook/testing/vite`). The package's `vite.config.ts` beside its specs exports it.
|
|
7
7
|
* Vite serves files up to its workspace root (the monorepo's, or the package's alone), which covers the package's
|
|
8
8
|
* sources, the libraries it builds on and this kit's fonts.
|
|
9
9
|
*
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* are the same as in CI, where the tests run inside that image.
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
|
-
* Published (`forgebook/testing/visual-browser
|
|
6
|
+
* Published (`forgebook/testing/visual-browser`). A package's `visualBrowser.ts` beside its specs
|
|
7
7
|
* exports a global setup that calls `startVisualBrowser` with its own port and container name and returns the
|
|
8
8
|
* teardown. Needs Docker (OrbStack or Docker Desktop).
|
|
9
9
|
*
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forgebook/testing",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Tests from a package's stories: each story and variant in the browser with axe, spills and overlays, screenshots, and each story rendered on the server.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/
|
|
8
|
+
"url": "git+https://github.com/ensiria/forgebook.git",
|
|
9
9
|
"directory": "packages/testing"
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
@@ -56,13 +56,13 @@
|
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@axe-core/playwright": "4.14.0",
|
|
58
58
|
"@ensiria/cli-kit": "^0.1.1",
|
|
59
|
-
"@forgebook/story-format": "0.1.
|
|
59
|
+
"@forgebook/story-format": "0.1.2"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@playwright/test": "^1.64.0",
|
|
63
63
|
"vite": "^8.0.0",
|
|
64
64
|
"vitest": "^5.0.0",
|
|
65
|
-
"forgebook": "^0.1.
|
|
65
|
+
"forgebook": "^0.1.2"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@playwright/test": "1.64.1",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"vitest": "5.0.5",
|
|
74
74
|
"@forgebook/tools": "0.0.0",
|
|
75
75
|
"@forgebook/typescript-config": "0.0.0",
|
|
76
|
-
"forgebook": "0.1.
|
|
76
|
+
"forgebook": "0.1.2"
|
|
77
77
|
},
|
|
78
78
|
"publishConfig": {
|
|
79
79
|
"access": "public"
|