@nestjs/testing 12.0.4 → 12.1.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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/testing-module.js +13 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/testing",
3
- "version": "12.0.4",
3
+ "version": "12.1.0",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@testing)",
5
5
  "author": "Kamil Mysliwiec",
6
6
  "license": "MIT",
@@ -41,5 +41,5 @@
41
41
  "optional": true
42
42
  }
43
43
  },
44
- "gitHead": "899dbe3a0c1e59d1d0fb7e0c7ad0b2d2aa4ae771"
44
+ "gitHead": "6739656fa3e8c98bd55883f0363a2254e6412232"
45
45
  }
package/testing-module.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Logger, } from '@nestjs/common';
2
2
  import { NestApplication, NestApplicationContext, } from '@nestjs/core';
3
- import { tryLoadPackage, loadPackageCached, isUndefined, } from '@nestjs/common/internal';
3
+ import { tryLoadPackage, loadPackageCached, isFunction, isUndefined, } from '@nestjs/common/internal';
4
4
  /**
5
5
  * @publicApi
6
6
  */
@@ -50,13 +50,23 @@ export class TestingModule extends NestApplicationContext {
50
50
  Logger.overrideLogger(options.logger);
51
51
  }
52
52
  createAdapterProxy(app, adapter) {
53
- return new Proxy(app, {
53
+ const proxy = new Proxy(app, {
54
54
  get: (receiver, prop) => {
55
55
  if (!(prop in receiver) && prop in adapter) {
56
- return adapter[prop];
56
+ const value = adapter[prop];
57
+ if (!isFunction(value)) {
58
+ return value;
59
+ }
60
+ // Called on the adapter, as on applications created by NestFactory.
61
+ // Chainable methods keep returning the application.
62
+ return (...args) => {
63
+ const result = value.apply(adapter, args);
64
+ return result === adapter ? proxy : result;
65
+ };
57
66
  }
58
67
  return receiver[prop];
59
68
  },
60
69
  });
70
+ return proxy;
61
71
  }
62
72
  }