@ultimat3/testing 31.41.0 → 31.42.1
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 +22 -22
- package/src/errors.ts +2 -0
- package/src/fixture-island.ts +27 -6
- package/src/island-errors.ts +16 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/testing",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.42.1",
|
|
4
4
|
"description": "Test harness: cloned template DBs per worker, frozen clock, sealed network, 6 test types",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ultimate",
|
|
@@ -47,27 +47,27 @@
|
|
|
47
47
|
"test": "bun test"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@ultimat3/action": "31.
|
|
51
|
-
"@ultimat3/ai": "31.
|
|
52
|
-
"@ultimat3/auth": "31.
|
|
53
|
-
"@ultimat3/cache": "31.
|
|
54
|
-
"@ultimat3/core": "31.
|
|
55
|
-
"@ultimat3/db": "31.
|
|
56
|
-
"@ultimat3/entity": "31.
|
|
57
|
-
"@ultimat3/http": "31.
|
|
58
|
-
"@ultimat3/i18n": "31.
|
|
59
|
-
"@ultimat3/jobs": "31.
|
|
60
|
-
"@ultimat3/mail": "31.
|
|
61
|
-
"@ultimat3/notify": "31.
|
|
62
|
-
"@ultimat3/policy": "31.
|
|
63
|
-
"@ultimat3/pwa": "31.
|
|
64
|
-
"@ultimat3/query": "31.
|
|
65
|
-
"@ultimat3/realtime": "31.
|
|
66
|
-
"@ultimat3/render": "31.
|
|
67
|
-
"@ultimat3/schema": "31.
|
|
68
|
-
"@ultimat3/scraping": "31.
|
|
69
|
-
"@ultimat3/seo": "31.
|
|
70
|
-
"@ultimat3/time": "31.
|
|
50
|
+
"@ultimat3/action": "31.42.1",
|
|
51
|
+
"@ultimat3/ai": "31.42.1",
|
|
52
|
+
"@ultimat3/auth": "31.42.1",
|
|
53
|
+
"@ultimat3/cache": "31.42.1",
|
|
54
|
+
"@ultimat3/core": "31.42.1",
|
|
55
|
+
"@ultimat3/db": "31.42.1",
|
|
56
|
+
"@ultimat3/entity": "31.42.1",
|
|
57
|
+
"@ultimat3/http": "31.42.1",
|
|
58
|
+
"@ultimat3/i18n": "31.42.1",
|
|
59
|
+
"@ultimat3/jobs": "31.42.1",
|
|
60
|
+
"@ultimat3/mail": "31.42.1",
|
|
61
|
+
"@ultimat3/notify": "31.42.1",
|
|
62
|
+
"@ultimat3/policy": "31.42.1",
|
|
63
|
+
"@ultimat3/pwa": "31.42.1",
|
|
64
|
+
"@ultimat3/query": "31.42.1",
|
|
65
|
+
"@ultimat3/realtime": "31.42.1",
|
|
66
|
+
"@ultimat3/render": "31.42.1",
|
|
67
|
+
"@ultimat3/schema": "31.42.1",
|
|
68
|
+
"@ultimat3/scraping": "31.42.1",
|
|
69
|
+
"@ultimat3/seo": "31.42.1",
|
|
70
|
+
"@ultimat3/time": "31.42.1"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"solid-js": "^1.9.18"
|
package/src/errors.ts
CHANGED
|
@@ -82,6 +82,7 @@ export const TESTING_ERROR_CODES = [
|
|
|
82
82
|
'X_TEST_PROPERTY_FAILED',
|
|
83
83
|
'X_TEST_SOAK_HEAP_GROWTH',
|
|
84
84
|
'X_TEST_TEMP_TREE_LEFT',
|
|
85
|
+
'X_TEST_ISLAND_BUILD_REUSED',
|
|
85
86
|
] as const;
|
|
86
87
|
|
|
87
88
|
export type TestingErrorCode = (typeof TESTING_ERROR_CODES)[number];
|
|
@@ -167,6 +168,7 @@ export const TESTING_ERROR_TITLES: Readonly<Record<TestingErrorCode, string>> =
|
|
|
167
168
|
X_TEST_PROPERTY_FAILED: 'a property() run found an input its claim refuses',
|
|
168
169
|
X_TEST_SOAK_HEAP_GROWTH: 'a soak() run grew the live heap past its stated bound',
|
|
169
170
|
X_TEST_TEMP_TREE_LEFT: 'a temp tree survived its own remove',
|
|
171
|
+
X_TEST_ISLAND_BUILD_REUSED: 'an island builder answered the shipped build with the coverage one',
|
|
170
172
|
};
|
|
171
173
|
|
|
172
174
|
// Titles must be registered for `format()` to render the contract's first line. Every code above is
|
package/src/fixture-island.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { basename, join } from 'node:path';
|
|
|
8
8
|
import { onFileBoundary } from './file-boundary';
|
|
9
9
|
import { islandCoverageDir, recordChunkMap } from './fixture-island-coverage';
|
|
10
10
|
import { createIslandDocument, FakeElement, handlerFor, parseHtml } from './island-dom';
|
|
11
|
-
import { islandMountMissing, islandNotBuilt } from './island-errors';
|
|
11
|
+
import { IslandBuildReusedError, islandMountMissing, islandNotBuilt } from './island-errors';
|
|
12
12
|
import { installGlobals } from './island-globals';
|
|
13
13
|
import type { ResizeInput } from './island-observers';
|
|
14
14
|
import { deliverResize } from './island-observers';
|
|
@@ -208,6 +208,22 @@ export function disposeLiveIslands(): number {
|
|
|
208
208
|
// guard that runs the boundary, and a mount a file forgot is one only this module can see.
|
|
209
209
|
onFileBoundary(disposeLiveIslands);
|
|
210
210
|
|
|
211
|
+
/**
|
|
212
|
+
* The shipped chunk's source, from the second build a coverage run asks for. The SAME bundle back
|
|
213
|
+
* is a memo that ignored `options` (`X_TEST_ISLAND_BUILD_REUSED`); a builder that ignores
|
|
214
|
+
* `coverage` altogether answers a fresh bundle and its chunk is what it is.
|
|
215
|
+
*/
|
|
216
|
+
async function shippedCode(
|
|
217
|
+
file: string,
|
|
218
|
+
shipped: Promise<IslandBundleLike>,
|
|
219
|
+
covered: IslandBundleLike,
|
|
220
|
+
chunk: IslandChunkLike,
|
|
221
|
+
): Promise<string> {
|
|
222
|
+
const bundle = await shipped;
|
|
223
|
+
if (bundle === covered) throw new IslandBuildReusedError({ file });
|
|
224
|
+
return bundle.chunks.find((each) => each.file === file)?.code ?? chunk.code;
|
|
225
|
+
}
|
|
226
|
+
|
|
211
227
|
export async function mountIsland(options: MountIslandOptions): Promise<MountedIsland> {
|
|
212
228
|
// `only`, because this fixture has always KNOWN which island it wants and asked for all of them
|
|
213
229
|
// anyway — `island-bundle.ts` added the option for exactly this caller ("a test that mounts a
|
|
@@ -223,10 +239,17 @@ export async function mountIsland(options: MountIslandOptions): Promise<MountedI
|
|
|
223
239
|
// being the faster and more honest call regardless. A builder that ignores the argument still
|
|
224
240
|
// works: the `find` below is unchanged.
|
|
225
241
|
const coverage = islandCoverageDir();
|
|
226
|
-
const
|
|
242
|
+
const covered = options.build(options.root, {
|
|
227
243
|
only: options.file,
|
|
228
244
|
...(coverage === undefined ? {} : { coverage: true }),
|
|
229
245
|
});
|
|
246
|
+
// Under coverage the shipped build is asked at the same time, not after: two builds in sequence
|
|
247
|
+
// doubled a mount's time and sent a 5 s test over its budget on a loaded runner.
|
|
248
|
+
const shippedBuild =
|
|
249
|
+
coverage === undefined ? undefined : options.build(options.root, { only: options.file });
|
|
250
|
+
// A covered build that rejects is what the caller sees; the shipped one is not left unawaited.
|
|
251
|
+
shippedBuild?.catch(() => undefined);
|
|
252
|
+
const bundle = await covered;
|
|
230
253
|
const chunk = bundle.chunks.find((each) => each.file === options.file);
|
|
231
254
|
if (chunk === undefined) {
|
|
232
255
|
throw islandNotBuilt(
|
|
@@ -239,11 +262,9 @@ export async function mountIsland(options: MountIslandOptions): Promise<MountedI
|
|
|
239
262
|
// What `code` answers is what ships: a coverage build keeps whitespace for its map, and an app's
|
|
240
263
|
// size ceiling read it as the chunk (31.27–31.40: green under `bun test`, red in `x verify`).
|
|
241
264
|
const shipped =
|
|
242
|
-
|
|
265
|
+
shippedBuild === undefined
|
|
243
266
|
? chunk.code
|
|
244
|
-
:
|
|
245
|
-
(each) => each.file === options.file,
|
|
246
|
-
)?.code ?? chunk.code);
|
|
267
|
+
: await shippedCode(options.file, shippedBuild, bundle, chunk);
|
|
247
268
|
|
|
248
269
|
const { documentElement, globals, resizeObservers } = createIslandDocument();
|
|
249
270
|
const restore = installGlobals({ ...globals, ...options.globals });
|
package/src/island-errors.ts
CHANGED
|
@@ -80,3 +80,19 @@ export class IslandMountMissingError extends UltimateError {
|
|
|
80
80
|
|
|
81
81
|
export const islandMountMissing = (file: string, exported: readonly string[]): UltimateError =>
|
|
82
82
|
new IslandMountMissingError({ file, exported });
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Under the gate's coverage run a mount asks its builder twice — covered to run, shipped for `code`
|
|
86
|
+
* — and got the SAME bundle back: a memo round `buildIslands` that ignores `options`. Measured
|
|
87
|
+
* instead, every size ceiling would read the unminified chunk, green under `bun test` and red in
|
|
88
|
+
* `x verify`.
|
|
89
|
+
*/
|
|
90
|
+
export class IslandBuildReusedError extends UltimateError {
|
|
91
|
+
constructor(input: { file: string }) {
|
|
92
|
+
super({
|
|
93
|
+
code: 'X_TEST_ISLAND_BUILD_REUSED',
|
|
94
|
+
cause: `the builder handed ${renderCauseValue(input.file)}'s mount the same bundle for the coverage build and the shipped one, so code would be the unminified chunk`,
|
|
95
|
+
fix: 'mountIsland({ build: buildIslands, root, file }) # the builder itself (describeIslandState already builds once per file), or key your memo by options.coverage',
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|