@ultimat3/testing 31.42.0 → 31.43.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": "@ultimat3/testing",
3
- "version": "31.42.0",
3
+ "version": "31.43.0",
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.42.0",
51
- "@ultimat3/ai": "31.42.0",
52
- "@ultimat3/auth": "31.42.0",
53
- "@ultimat3/cache": "31.42.0",
54
- "@ultimat3/core": "31.42.0",
55
- "@ultimat3/db": "31.42.0",
56
- "@ultimat3/entity": "31.42.0",
57
- "@ultimat3/http": "31.42.0",
58
- "@ultimat3/i18n": "31.42.0",
59
- "@ultimat3/jobs": "31.42.0",
60
- "@ultimat3/mail": "31.42.0",
61
- "@ultimat3/notify": "31.42.0",
62
- "@ultimat3/policy": "31.42.0",
63
- "@ultimat3/pwa": "31.42.0",
64
- "@ultimat3/query": "31.42.0",
65
- "@ultimat3/realtime": "31.42.0",
66
- "@ultimat3/render": "31.42.0",
67
- "@ultimat3/schema": "31.42.0",
68
- "@ultimat3/scraping": "31.42.0",
69
- "@ultimat3/seo": "31.42.0",
70
- "@ultimat3/time": "31.42.0"
50
+ "@ultimat3/action": "31.43.0",
51
+ "@ultimat3/ai": "31.43.0",
52
+ "@ultimat3/auth": "31.43.0",
53
+ "@ultimat3/cache": "31.43.0",
54
+ "@ultimat3/core": "31.43.0",
55
+ "@ultimat3/db": "31.43.0",
56
+ "@ultimat3/entity": "31.43.0",
57
+ "@ultimat3/http": "31.43.0",
58
+ "@ultimat3/i18n": "31.43.0",
59
+ "@ultimat3/jobs": "31.43.0",
60
+ "@ultimat3/mail": "31.43.0",
61
+ "@ultimat3/notify": "31.43.0",
62
+ "@ultimat3/policy": "31.43.0",
63
+ "@ultimat3/pwa": "31.43.0",
64
+ "@ultimat3/query": "31.43.0",
65
+ "@ultimat3/realtime": "31.43.0",
66
+ "@ultimat3/render": "31.43.0",
67
+ "@ultimat3/schema": "31.43.0",
68
+ "@ultimat3/scraping": "31.43.0",
69
+ "@ultimat3/seo": "31.43.0",
70
+ "@ultimat3/time": "31.43.0"
71
71
  },
72
72
  "peerDependencies": {
73
73
  "solid-js": "^1.9.18"
@@ -53,7 +53,7 @@ export function seededUuid(seed: number): () => string {
53
53
  return () => `${hex(8)}-${hex(4)}-4${hex(3)}-a${hex(3)}-${hex(12)}`;
54
54
  }
55
55
 
56
- class FrozenDate extends RealDate {
56
+ class FrozenClassDate extends RealDate {
57
57
  constructor(...args: readonly unknown[]) {
58
58
  if (args.length === 0) {
59
59
  super(frozenAt);
@@ -95,6 +95,17 @@ class FrozenDate extends RealDate {
95
95
  }
96
96
  }
97
97
 
98
+ /**
99
+ * What `globalThis.Date` is while installed. A `class` cannot be called without `new`, so
100
+ * `Date()` — the real one answers the current time's string — threw a TypeError under every test
101
+ * preload. The `apply` trap answers the frozen instant's string, ignoring arguments as the real
102
+ * call does; `new`, the statics, `instanceof` and `extends Date` all fall through to the class.
103
+ * One Proxy for the process, so a snapshot's `date` compares by identity.
104
+ */
105
+ const FrozenDate = new Proxy(FrozenClassDate, {
106
+ apply: (): string => new RealDate(frozenAt).toString(),
107
+ });
108
+
98
109
  export interface DeterminismOptions {
99
110
  readonly seed?: number;
100
111
  readonly now?: string | number;
@@ -209,18 +209,19 @@ export function disposeLiveIslands(): number {
209
209
  onFileBoundary(disposeLiveIslands);
210
210
 
211
211
  /**
212
- * The shipped chunk's source, asked of the builder a second time under a coverage run. The SAME
213
- * bundle back is a memo that ignored `options` (`X_TEST_ISLAND_BUILD_REUSED`); a builder that
214
- * ignores `coverage` altogether answers a fresh bundle and its chunk is what it is.
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
215
  */
216
216
  async function shippedCode(
217
- options: MountIslandOptions,
217
+ file: string,
218
+ shipped: Promise<IslandBundleLike>,
218
219
  covered: IslandBundleLike,
219
220
  chunk: IslandChunkLike,
220
221
  ): Promise<string> {
221
- const bundle = await options.build(options.root, { only: options.file });
222
- if (bundle === covered) throw new IslandBuildReusedError({ file: options.file });
223
- return bundle.chunks.find((each) => each.file === options.file)?.code ?? chunk.code;
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;
224
225
  }
225
226
 
226
227
  export async function mountIsland(options: MountIslandOptions): Promise<MountedIsland> {
@@ -238,10 +239,17 @@ export async function mountIsland(options: MountIslandOptions): Promise<MountedI
238
239
  // being the faster and more honest call regardless. A builder that ignores the argument still
239
240
  // works: the `find` below is unchanged.
240
241
  const coverage = islandCoverageDir();
241
- const bundle = await options.build(options.root, {
242
+ const covered = options.build(options.root, {
242
243
  only: options.file,
243
244
  ...(coverage === undefined ? {} : { coverage: true }),
244
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;
245
253
  const chunk = bundle.chunks.find((each) => each.file === options.file);
246
254
  if (chunk === undefined) {
247
255
  throw islandNotBuilt(
@@ -253,7 +261,10 @@ export async function mountIsland(options: MountIslandOptions): Promise<MountedI
253
261
 
254
262
  // What `code` answers is what ships: a coverage build keeps whitespace for its map, and an app's
255
263
  // size ceiling read it as the chunk (31.27–31.40: green under `bun test`, red in `x verify`).
256
- const shipped = coverage === undefined ? chunk.code : await shippedCode(options, bundle, chunk);
264
+ const shipped =
265
+ shippedBuild === undefined
266
+ ? chunk.code
267
+ : await shippedCode(options.file, shippedBuild, bundle, chunk);
257
268
 
258
269
  const { documentElement, globals, resizeObservers } = createIslandDocument();
259
270
  const restore = installGlobals({ ...globals, ...options.globals });