@noego/testing 0.7.4 → 0.7.6
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/dist/browser/index.js +3 -3
- package/dist/index.cjs +16 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -22
- package/dist/index.js.map +1 -1
- package/package.json +8 -5
package/dist/browser/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
followFetchRedirects
|
|
3
|
-
} from "../chunk-YX44DAOH.js";
|
|
4
1
|
import {
|
|
5
2
|
acquireNativeBrowser,
|
|
6
3
|
startSharedBrowser
|
|
7
4
|
} from "../chunk-P26IJDOI.js";
|
|
5
|
+
import {
|
|
6
|
+
followFetchRedirects
|
|
7
|
+
} from "../chunk-YX44DAOH.js";
|
|
8
8
|
import "../chunk-DGUM43GV.js";
|
|
9
9
|
|
|
10
10
|
// src/browser/lifecycle.ts
|
package/dist/index.cjs
CHANGED
|
@@ -385,7 +385,6 @@ function recordOutcome(call, outcome, threw) {
|
|
|
385
385
|
else call.result = outcome;
|
|
386
386
|
return outcome;
|
|
387
387
|
}
|
|
388
|
-
var pristineMethods = /* @__PURE__ */ new WeakMap();
|
|
389
388
|
function createMethodDecorator(registry) {
|
|
390
389
|
const wrappers = /* @__PURE__ */ new WeakMap();
|
|
391
390
|
return function decorate(instance, token2) {
|
|
@@ -406,18 +405,6 @@ function createMethodDecorator(registry) {
|
|
|
406
405
|
throw new MethodNotCallableError(tokenLabel(token2), method);
|
|
407
406
|
}
|
|
408
407
|
}
|
|
409
|
-
if (Object.isExtensible(instance)) {
|
|
410
|
-
const pristine = pristineMethods.get(instance) ?? /* @__PURE__ */ new Map();
|
|
411
|
-
pristineMethods.set(instance, pristine);
|
|
412
|
-
for (const [method, { entryKey, descriptor }] of effective) {
|
|
413
|
-
const original = pristine.get(method) ?? instance[method];
|
|
414
|
-
pristine.set(method, original);
|
|
415
|
-
const wrapped = buildMethodWrapper(instance, method, descriptor, registry.state(entryKey, method), original);
|
|
416
|
-
Object.defineProperty(instance, method, { value: wrapped, configurable: true, writable: true, enumerable: false });
|
|
417
|
-
}
|
|
418
|
-
wrappers.set(instance, instance);
|
|
419
|
-
return instance;
|
|
420
|
-
}
|
|
421
408
|
const methodCache = /* @__PURE__ */ new Map();
|
|
422
409
|
const proxy = new Proxy(instance, {
|
|
423
410
|
get(target, prop, receiver) {
|
|
@@ -425,7 +412,7 @@ function createMethodDecorator(registry) {
|
|
|
425
412
|
let wrapped = methodCache.get(prop);
|
|
426
413
|
if (!wrapped) {
|
|
427
414
|
const { entryKey, descriptor } = effective.get(prop);
|
|
428
|
-
wrapped = buildMethodWrapper(target, prop, descriptor, registry.state(entryKey, prop)
|
|
415
|
+
wrapped = buildMethodWrapper(target, prop, descriptor, registry.state(entryKey, prop));
|
|
429
416
|
methodCache.set(prop, wrapped);
|
|
430
417
|
}
|
|
431
418
|
return wrapped;
|
|
@@ -438,9 +425,10 @@ function createMethodDecorator(registry) {
|
|
|
438
425
|
return proxy;
|
|
439
426
|
};
|
|
440
427
|
}
|
|
441
|
-
function buildMethodWrapper(target, method, descriptor, state
|
|
428
|
+
function buildMethodWrapper(target, method, descriptor, state) {
|
|
442
429
|
const callOriginal = (self, args) => {
|
|
443
|
-
|
|
430
|
+
const fn = target[method];
|
|
431
|
+
return fn.apply(self === void 0 ? target : self, args);
|
|
444
432
|
};
|
|
445
433
|
if (typeof descriptor === "function") {
|
|
446
434
|
const replacement = descriptor((...args) => callOriginal(target, args));
|
|
@@ -1356,6 +1344,12 @@ function assertTestLanes(required, reports) {
|
|
|
1356
1344
|
}
|
|
1357
1345
|
|
|
1358
1346
|
// src/overlays.ts
|
|
1347
|
+
var import_ioc3 = require("@noego/ioc");
|
|
1348
|
+
function admittedClassBinding(token2) {
|
|
1349
|
+
return (0, import_ioc3.flattenModule)((0, import_ioc3.defineModule)("@noego/testing/admitted", (bind) => {
|
|
1350
|
+
bind(token2).toSelf();
|
|
1351
|
+
}))[0];
|
|
1352
|
+
}
|
|
1359
1353
|
var TestOverlayError = class extends Error {
|
|
1360
1354
|
constructor(message, entry) {
|
|
1361
1355
|
super("entry " + entry.provenance.join(".") + ": " + message);
|
|
@@ -1397,7 +1391,7 @@ function resolveTestOverlays(stub, catalogs) {
|
|
|
1397
1391
|
if (candidates.length === 0 && entry.kind !== "middleware" && entry.kind !== "load" && (typeof entry.target === "function" || entry.kind === "value")) {
|
|
1398
1392
|
const fallback = catalogs.filter((c) => entry.owner === void 0 || c.owner === entry.owner);
|
|
1399
1393
|
if (fallback.length === 1) {
|
|
1400
|
-
const synthetic = typeof entry.target === "function" ?
|
|
1394
|
+
const synthetic = typeof entry.target === "function" ? admittedClassBinding(entry.target) : { token: entry.target, kind: "value", lifetime: "singleton", implementation: entry.replacement, dependencies: [] };
|
|
1401
1395
|
candidates = [{ ...fallback[0], bindings: [...fallback[0].bindings, synthetic] }];
|
|
1402
1396
|
}
|
|
1403
1397
|
}
|
|
@@ -1419,7 +1413,7 @@ function resolveTestOverlays(stub, catalogs) {
|
|
|
1419
1413
|
}
|
|
1420
1414
|
|
|
1421
1415
|
// src/binding_overlays.ts
|
|
1422
|
-
var
|
|
1416
|
+
var import_ioc4 = require("@noego/ioc");
|
|
1423
1417
|
function applyTestBindings(production, overlays, owner) {
|
|
1424
1418
|
let builder = production;
|
|
1425
1419
|
const entries = overlays.filter((e) => e.owner === owner);
|
|
@@ -1428,7 +1422,7 @@ function applyTestBindings(production, overlays, owner) {
|
|
|
1428
1422
|
const { entry, binding: binding2 } = overlay;
|
|
1429
1423
|
if (entry.kind === "middleware" || entry.kind === "load" || entry.kind === "method") continue;
|
|
1430
1424
|
if (!binding2) throw new TestOverlayError("missing production binding metadata", entry);
|
|
1431
|
-
builder = builder.use((0,
|
|
1425
|
+
builder = builder.use((0, import_ioc4.defineModule)("@noego/testing/" + owner + "/" + entry.provenance.join("."), (bind) => {
|
|
1432
1426
|
if (entry.kind === "class") {
|
|
1433
1427
|
bind(entry.target).to(entry.replacement)[binding2.lifetime]();
|
|
1434
1428
|
} else if (entry.kind === "function" && binding2.kind === "factory") {
|
|
@@ -1493,15 +1487,15 @@ function createTestExecutables(overlays, owner) {
|
|
|
1493
1487
|
}
|
|
1494
1488
|
|
|
1495
1489
|
// src/binding_catalog.ts
|
|
1496
|
-
var
|
|
1490
|
+
var import_ioc5 = require("@noego/ioc");
|
|
1497
1491
|
function describeTestBindings(builder, discovered = []) {
|
|
1498
1492
|
const declarations = /* @__PURE__ */ new Map();
|
|
1499
|
-
const classBinding = (token2, implementation) => (0,
|
|
1493
|
+
const classBinding = (token2, implementation) => (0, import_ioc5.flattenModule)((0, import_ioc5.defineModule)("@noego/testing/discovered", (bind) => {
|
|
1500
1494
|
bind(token2).to(implementation);
|
|
1501
1495
|
}))[0];
|
|
1502
1496
|
for (const write of builder.writes) {
|
|
1503
1497
|
if (write.op === "use") {
|
|
1504
|
-
for (const registration of (0,
|
|
1498
|
+
for (const registration of (0, import_ioc5.flattenModule)(write.module)) declarations.set(registration.token, registration);
|
|
1505
1499
|
} else if (write.op === "classes") {
|
|
1506
1500
|
const registration = classBinding(write.key, write.implementation);
|
|
1507
1501
|
declarations.set(write.key, { ...registration, lifetime: declarations.get(write.key)?.lifetime ?? registration.lifetime });
|