@noego/testing 0.7.2 → 0.7.4

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.
@@ -1,10 +1,10 @@
1
+ import {
2
+ followFetchRedirects
3
+ } from "../chunk-YX44DAOH.js";
1
4
  import {
2
5
  acquireNativeBrowser,
3
6
  startSharedBrowser
4
7
  } 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,6 +385,7 @@ function recordOutcome(call, outcome, threw) {
385
385
  else call.result = outcome;
386
386
  return outcome;
387
387
  }
388
+ var pristineMethods = /* @__PURE__ */ new WeakMap();
388
389
  function createMethodDecorator(registry) {
389
390
  const wrappers = /* @__PURE__ */ new WeakMap();
390
391
  return function decorate(instance, token2) {
@@ -405,6 +406,18 @@ function createMethodDecorator(registry) {
405
406
  throw new MethodNotCallableError(tokenLabel(token2), method);
406
407
  }
407
408
  }
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
+ }
408
421
  const methodCache = /* @__PURE__ */ new Map();
409
422
  const proxy = new Proxy(instance, {
410
423
  get(target, prop, receiver) {
@@ -412,7 +425,7 @@ function createMethodDecorator(registry) {
412
425
  let wrapped = methodCache.get(prop);
413
426
  if (!wrapped) {
414
427
  const { entryKey, descriptor } = effective.get(prop);
415
- wrapped = buildMethodWrapper(target, prop, descriptor, registry.state(entryKey, prop));
428
+ wrapped = buildMethodWrapper(target, prop, descriptor, registry.state(entryKey, prop), target[prop]);
416
429
  methodCache.set(prop, wrapped);
417
430
  }
418
431
  return wrapped;
@@ -425,10 +438,9 @@ function createMethodDecorator(registry) {
425
438
  return proxy;
426
439
  };
427
440
  }
428
- function buildMethodWrapper(target, method, descriptor, state) {
441
+ function buildMethodWrapper(target, method, descriptor, state, original) {
429
442
  const callOriginal = (self, args) => {
430
- const fn = target[method];
431
- return fn.apply(self === void 0 ? target : self, args);
443
+ return original.apply(self === void 0 ? target : self, args);
432
444
  };
433
445
  if (typeof descriptor === "function") {
434
446
  const replacement = descriptor((...args) => callOriginal(target, args));