@cosmicdrift/kumiko-testing 0.365.0 → 0.366.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmicdrift/kumiko-testing",
3
- "version": "0.365.0",
3
+ "version": "0.366.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": "BUSL-1.1",
6
6
  "author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
@@ -79,10 +79,10 @@
79
79
  "kumiko-testing": "./bin/kumiko-testing.ts"
80
80
  },
81
81
  "dependencies": {
82
- "@cosmicdrift/kumiko-bundled-features": "0.365.0",
83
- "@cosmicdrift/kumiko-dev-server": "0.365.0",
84
- "@cosmicdrift/kumiko-framework": "0.365.0",
85
- "@cosmicdrift/kumiko-types": "0.365.0",
82
+ "@cosmicdrift/kumiko-bundled-features": "0.366.0",
83
+ "@cosmicdrift/kumiko-dev-server": "0.366.0",
84
+ "@cosmicdrift/kumiko-framework": "0.366.0",
85
+ "@cosmicdrift/kumiko-types": "0.366.0",
86
86
  "zod": "^4.4.3"
87
87
  },
88
88
  "peerDependencies": {
@@ -0,0 +1,38 @@
1
+ import {
2
+ ERROR_BOUNDARY_LOG_MARKER,
3
+ ROOT_ERROR_FALLBACK_TEST_ID,
4
+ SCREEN_ERROR_FALLBACK_TEST_ID,
5
+ } from "@cosmicdrift/kumiko-types/error-boundary";
6
+ import { test as base, expect } from "@playwright/test";
7
+
8
+ // An error boundary keeps the page alive, which also hides the failure from `pageerror`.
9
+ // Every spec using `test` from this package fails when a boundary caught something.
10
+ export const boundaryGuardedTest = base.extend<{
11
+ failOnErrorBoundary: undefined;
12
+ expectErrorBoundary: boolean;
13
+ }>({
14
+ expectErrorBoundary: [false, { option: true }],
15
+ failOnErrorBoundary: [
16
+ async ({ page, expectErrorBoundary }, use) => {
17
+ const boundaryLogs: string[] = [];
18
+ page.on("console", (msg) => {
19
+ if (msg.type() === "error" && msg.text().includes(ERROR_BOUNDARY_LOG_MARKER)) {
20
+ boundaryLogs.push(msg.text());
21
+ }
22
+ });
23
+ await use(undefined);
24
+ // skip: the spec provokes a boundary on purpose and asserts the fallback itself
25
+ if (expectErrorBoundary) return;
26
+ const visibleFallbacks = await page
27
+ .locator(
28
+ `[data-testid="${SCREEN_ERROR_FALLBACK_TEST_ID}"], [data-testid="${ROOT_ERROR_FALLBACK_TEST_ID}"]`,
29
+ )
30
+ .count();
31
+ expect(
32
+ { boundaryLogs, visibleFallbacks },
33
+ "an error boundary caught a render/effect error",
34
+ ).toEqual({ boundaryLogs: [], visibleFallbacks: 0 });
35
+ },
36
+ { auto: true },
37
+ ],
38
+ });
package/src/e2e/index.ts CHANGED
@@ -21,6 +21,7 @@ export {
21
21
  syntheticClientIpFor,
22
22
  totpCode,
23
23
  } from "./auth-kit";
24
+ export { boundaryGuardedTest } from "./boundary-guard";
24
25
  export {
25
26
  CSRF_COOKIE_NAME,
26
27
  CSRF_HEADER_NAME,
@@ -1,14 +1,13 @@
1
1
  import { ROLES } from "@cosmicdrift/kumiko-framework/auth";
2
- import {
3
- type APIRequestContext,
4
- type BrowserContext,
5
- test as base,
6
- type Page,
7
- type Request as PlaywrightRequest,
8
- type PlaywrightTestArgs,
9
- type PlaywrightTestOptions,
10
- type PlaywrightWorkerArgs,
11
- type TestInfo,
2
+ import type {
3
+ APIRequestContext,
4
+ BrowserContext,
5
+ Page,
6
+ Request as PlaywrightRequest,
7
+ PlaywrightTestArgs,
8
+ PlaywrightTestOptions,
9
+ PlaywrightWorkerArgs,
10
+ TestInfo,
12
11
  } from "@playwright/test";
13
12
  import type * as z from "zod";
14
13
  import {
@@ -29,6 +28,7 @@ import {
29
28
  loginViaApi,
30
29
  syntheticClientIpFor,
31
30
  } from "./auth-kit";
31
+ import { boundaryGuardedTest as base } from "./boundary-guard";
32
32
  import { SEED_ROUTES, SEED_TOKEN_ENV } from "./constants";
33
33
  import { seedRouteHeaders } from "./mail-capture";
34
34
  import {