@cosmicdrift/kumiko-testing 0.410.0 → 0.411.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/package.json +6 -6
- package/src/changes.json +12 -0
- package/src/e2e/screenshots.ts +3 -1
- package/src/scaffold-blank.ts +48 -0
- package/src/scaffold.ts +21 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmicdrift/kumiko-testing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.411.0",
|
|
4
4
|
"description": "Test template for Kumiko apps: per-flow seedTenant, app test stack, canonical test preloads, bunfig generator and integration runner.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
|
|
@@ -103,9 +103,9 @@
|
|
|
103
103
|
"kumiko-testing": "./bin/kumiko-testing.ts"
|
|
104
104
|
},
|
|
105
105
|
"dependencies": {
|
|
106
|
-
"@cosmicdrift/kumiko-framework": "0.
|
|
107
|
-
"@cosmicdrift/kumiko-guards": "0.
|
|
108
|
-
"@cosmicdrift/kumiko-types": "0.
|
|
106
|
+
"@cosmicdrift/kumiko-framework": "0.411.0",
|
|
107
|
+
"@cosmicdrift/kumiko-guards": "0.411.0",
|
|
108
|
+
"@cosmicdrift/kumiko-types": "0.411.0",
|
|
109
109
|
"zod": "^4.6.7"
|
|
110
110
|
},
|
|
111
111
|
"peerDependencies": {
|
|
@@ -129,8 +129,8 @@
|
|
|
129
129
|
}
|
|
130
130
|
},
|
|
131
131
|
"devDependencies": {
|
|
132
|
-
"@cosmicdrift/kumiko-bundled-features": "0.
|
|
133
|
-
"@cosmicdrift/kumiko-dev-server": "0.
|
|
132
|
+
"@cosmicdrift/kumiko-bundled-features": "0.411.0",
|
|
133
|
+
"@cosmicdrift/kumiko-dev-server": "0.411.0",
|
|
134
134
|
"@happy-dom/global-registrator": "^21.0.4",
|
|
135
135
|
"@playwright/test": "^1.64.1",
|
|
136
136
|
"@testing-library/dom": "^10.4.2",
|
package/src/changes.json
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.411.0",
|
|
4
|
+
"type": "improvement",
|
|
5
|
+
"title": "renderTestSetup starter \"blank\"",
|
|
6
|
+
"detail": "`renderTestSetup({ starter: \"blank\" })` skips the tasks integration and e2e files, ships a boot validation unit test and a boot integration test, and runs Playwright with `--pass-with-no-tests`."
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"version": "0.411.0",
|
|
10
|
+
"type": "fix",
|
|
11
|
+
"title": "runScreenshots finishes CSS transitions before the capture",
|
|
12
|
+
"detail": "`runScreenshots` captures with `animations: \"disabled\"` like `runMatrix`. A scenario flow that toggles the dark theme no longer catches `transition-all` buttons mid-fade with their light-theme colours."
|
|
13
|
+
},
|
|
2
14
|
{
|
|
3
15
|
"version": "0.409.0",
|
|
4
16
|
"type": "fix",
|
package/src/e2e/screenshots.ts
CHANGED
|
@@ -274,7 +274,9 @@ export function runScreenshots(scenarios: readonly Scenario[], opts: FlatOptions
|
|
|
274
274
|
presentIdentities: identities.register,
|
|
275
275
|
});
|
|
276
276
|
const path = `${outDir}/${s.name}.png`;
|
|
277
|
-
|
|
277
|
+
// Same as runMatrix: a theme toggle in the flow starts transition-all fades that
|
|
278
|
+
// the settle fingerprint cannot see, so finish them at capture time.
|
|
279
|
+
await captureScenario(page, s, identities.mappings, { path, animations: "disabled" });
|
|
278
280
|
expect.soft(statSync(path).size).toBeGreaterThan(MIN_BYTES);
|
|
279
281
|
},
|
|
280
282
|
);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// @runtime tooling
|
|
2
|
+
export type ScaffoldTestStarter = "demo" | "blank";
|
|
3
|
+
|
|
4
|
+
export const BLANK_E2E_PLAYWRIGHT_FLAG = "--pass-with-no-tests";
|
|
5
|
+
|
|
6
|
+
export const BLANK_TEST_FILES: Readonly<Record<string, string>> = {
|
|
7
|
+
"src/__tests__/run-config.test.ts": [
|
|
8
|
+
'import { describe, expect, test } from "bun:test";',
|
|
9
|
+
'import { validateBoot } from "@cosmicdrift/kumiko-framework/engine";',
|
|
10
|
+
'import { composeFeatures } from "@cosmicdrift/kumiko-server-runtime/compose-features";',
|
|
11
|
+
'import { APP_FEATURES, HAS_AUTH } from "../run-config";',
|
|
12
|
+
"",
|
|
13
|
+
'describe("run-config", () => {',
|
|
14
|
+
' test("the mounted features pass boot validation", () => {',
|
|
15
|
+
" const features = composeFeatures([...APP_FEATURES], { includeBundled: HAS_AUTH });",
|
|
16
|
+
" expect(() => validateBoot(features)).not.toThrow();",
|
|
17
|
+
" });",
|
|
18
|
+
"});",
|
|
19
|
+
"",
|
|
20
|
+
].join("\n"),
|
|
21
|
+
"src/__tests__/boot.integration.test.ts": [
|
|
22
|
+
'import { afterAll, beforeAll, describe, expect, test } from "bun:test";',
|
|
23
|
+
'import { setupAppTestStack } from "@cosmicdrift/kumiko-dev-server/testing";',
|
|
24
|
+
'import type { TestStack } from "@cosmicdrift/kumiko-testing/stack";',
|
|
25
|
+
'import { APP_FEATURES } from "../run-config";',
|
|
26
|
+
"",
|
|
27
|
+
"let stack: TestStack;",
|
|
28
|
+
"",
|
|
29
|
+
"beforeAll(async () => {",
|
|
30
|
+
" stack = await setupAppTestStack([...APP_FEATURES]);",
|
|
31
|
+
"});",
|
|
32
|
+
"",
|
|
33
|
+
"afterAll(async () => {",
|
|
34
|
+
" await stack?.cleanup();",
|
|
35
|
+
"});",
|
|
36
|
+
"",
|
|
37
|
+
'describe("boot", () => {',
|
|
38
|
+
' test("the mounted features boot and refuse an unknown login", async () => {',
|
|
39
|
+
' const res = await stack.http.raw("POST", "/api/auth/login", {',
|
|
40
|
+
' email: "nobody@example.com",',
|
|
41
|
+
' password: "not-a-real-password",',
|
|
42
|
+
" });",
|
|
43
|
+
" expect(res.status).toBeGreaterThanOrEqual(400);",
|
|
44
|
+
" });",
|
|
45
|
+
"});",
|
|
46
|
+
"",
|
|
47
|
+
].join("\n"),
|
|
48
|
+
};
|
package/src/scaffold.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
// @runtime tooling
|
|
2
2
|
import { BUNFIG_FILES, renderBunfigFiles, TEST_TIMEOUT_MS } from "./bunfig";
|
|
3
3
|
import { REAL_PROVIDERS_ENV } from "./helpers/real-providers";
|
|
4
|
+
import {
|
|
5
|
+
BLANK_E2E_PLAYWRIGHT_FLAG,
|
|
6
|
+
BLANK_TEST_FILES,
|
|
7
|
+
type ScaffoldTestStarter,
|
|
8
|
+
} from "./scaffold-blank";
|
|
4
9
|
|
|
5
10
|
export type ScaffoldTestSetup = {
|
|
6
11
|
readonly files: Readonly<Record<string, string>>;
|
|
@@ -13,6 +18,7 @@ export type RenderTestSetupInput = {
|
|
|
13
18
|
readonly appName: string;
|
|
14
19
|
readonly frameworkVersion: string;
|
|
15
20
|
readonly port?: number;
|
|
21
|
+
readonly starter?: ScaffoldTestStarter;
|
|
16
22
|
};
|
|
17
23
|
|
|
18
24
|
// One above the scaffold's `bun dev` default (4173) so both can run side by side.
|
|
@@ -202,19 +208,25 @@ function renderIntegrationTest(): string {
|
|
|
202
208
|
}
|
|
203
209
|
|
|
204
210
|
export function renderTestSetup(input: RenderTestSetupInput): ScaffoldTestSetup {
|
|
205
|
-
const { appName, frameworkVersion, port = SCAFFOLD_E2E_PORT } = input;
|
|
211
|
+
const { appName, frameworkVersion, port = SCAFFOLD_E2E_PORT, starter = "demo" } = input;
|
|
212
|
+
const isBlank = starter === "blank";
|
|
213
|
+
const playwrightRun = `bunx --bun playwright test${isBlank ? ` ${BLANK_E2E_PLAYWRIGHT_FLAG}` : ""}`;
|
|
206
214
|
const unitTestScript = `bun --config=${BUNFIG_FILES.unit} test --timeout=${TEST_TIMEOUT_MS.unit} --dots`;
|
|
207
215
|
const integrationTestScript = `bun kumiko-testing integration --parallel ${SCAFFOLD_INTEGRATION_PARALLEL}`;
|
|
208
216
|
return {
|
|
209
217
|
files: {
|
|
210
218
|
...renderBunfigFiles({ install: { linker: "hoisted" }, dom: true }),
|
|
211
219
|
"playwright.config.ts": renderPlaywrightConfig(port),
|
|
212
|
-
"e2e/_helpers/index.ts": renderE2eHelpers(),
|
|
213
220
|
"e2e/server.ts": renderE2eServer(appName),
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
221
|
+
...(isBlank
|
|
222
|
+
? BLANK_TEST_FILES
|
|
223
|
+
: {
|
|
224
|
+
"e2e/_helpers/index.ts": renderE2eHelpers(),
|
|
225
|
+
"e2e/smoke.spec.ts": renderE2eSmokeSpec(),
|
|
226
|
+
"src/__tests__/_setup.ts": renderIntegrationSetup(),
|
|
227
|
+
"src/__tests__/run-config.test.ts": renderUnitTest(),
|
|
228
|
+
"src/__tests__/tasks.integration.test.ts": renderIntegrationTest(),
|
|
229
|
+
}),
|
|
218
230
|
},
|
|
219
231
|
scripts: {
|
|
220
232
|
test: unitTestScript,
|
|
@@ -231,9 +243,9 @@ export function renderTestSetup(input: RenderTestSetupInput): ScaffoldTestSetup
|
|
|
231
243
|
// picks up the unit suite.
|
|
232
244
|
"test:real": `${REAL_PROVIDERS_ENV}=1 bun --config=${BUNFIG_FILES.real} test --timeout=${TEST_TIMEOUT_MS.real} .real.test.ts`,
|
|
233
245
|
"test:bunfig": "bun kumiko-testing bunfig --hoisted",
|
|
234
|
-
e2e:
|
|
235
|
-
"e2e:real": `${REAL_PROVIDERS_ENV}=1
|
|
236
|
-
screenshots:
|
|
246
|
+
e2e: playwrightRun,
|
|
247
|
+
"e2e:real": `${REAL_PROVIDERS_ENV}=1 ${playwrightRun}`,
|
|
248
|
+
screenshots: `SCREENSHOT_DIR=docs/screenshots ${playwrightRun}`,
|
|
237
249
|
},
|
|
238
250
|
devDependencies: {
|
|
239
251
|
"@cosmicdrift/kumiko-testing": frameworkVersion,
|