@nestjs/testing 12.0.0-alpha.2 → 12.0.0-alpha.3
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/Readme.md +2 -1
- package/package.json +2 -2
- package/testing-injector.d.ts +9 -2
- package/testing-injector.js +4 -4
- package/testing-module.builder.js +1 -0
package/Readme.md
CHANGED
|
@@ -29,7 +29,7 @@ Nest is a framework for building efficient, scalable <a href="https://nodejs.org
|
|
|
29
29
|
|
|
30
30
|
## Philosophy
|
|
31
31
|
|
|
32
|
-
<p>In recent years, thanks to Node.js, JavaScript has become the “lingua franca” of the web for both front and
|
|
32
|
+
<p>In recent years, thanks to Node.js, JavaScript has become the “lingua franca” of the web for both front-end and back-end applications, giving rise to awesome projects like <a href="https://angular.dev/" target="_blank">Angular</a>, <a href="https://react.dev/" target="_blank">React</a>, and <a href="https://vuejs.org/" target="_blank">Vue</a>, which improve developer productivity and enable the construction of fast, testable, and extensible frontend applications. However, on the server-side, while there are a lot of superb libraries, helpers, and tools for Node, none of them effectively solve the main problem - the architecture.</p>
|
|
33
33
|
<p>Nest aims to provide an application architecture out of the box which allows for effortless creation of highly testable, scalable, and loosely coupled and easily maintainable applications. The architecture is heavily inspired by Angular.</p>
|
|
34
34
|
|
|
35
35
|
## Getting started
|
|
@@ -95,6 +95,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
|
|
95
95
|
<td align="center" valign="middle"><a href="https://crawljobs.com" target="_blank"><img src="https://nestjs.com/img/logos/crawljobs-logo.svg" width="130" valign="middle" /></a></td>
|
|
96
96
|
</tr><tr>
|
|
97
97
|
<td align="center" valign="middle"><a href="https://pandektes.com" target="_blank"><img src="https://nestjs.com/img/logos/pandektes-logo.png" width="65" valign="middle" /></a></td>
|
|
98
|
+
<td align="center" valign="middle"><a href="https://www.fintechcrafts.com/" target="_blank"><img src="https://nestjs.com/img/logos/fintechcrafts-logo.svg" width="65" valign="middle" /></a></td>
|
|
98
99
|
</tr>
|
|
99
100
|
</table>
|
|
100
101
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/testing",
|
|
3
|
-
"version": "12.0.0-alpha.
|
|
3
|
+
"version": "12.0.0-alpha.3",
|
|
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": "
|
|
44
|
+
"gitHead": "1c9d5482a65a446ede8dd1195bfa1cbbc16e0857"
|
|
45
45
|
}
|
package/testing-injector.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { NestContainer } from '@nestjs/core';
|
|
2
|
+
import type { ContextId } from '@nestjs/core/injector/instance-wrapper.js';
|
|
2
3
|
import { MockFactory } from './interfaces/index.js';
|
|
3
4
|
import { Injector, type InjectorDependencyContext, InstanceWrapper, type Module } from '@nestjs/core/internal';
|
|
5
|
+
interface ResolutionContext {
|
|
6
|
+
contextId: ContextId;
|
|
7
|
+
inquirer?: InstanceWrapper;
|
|
8
|
+
effectiveInquirerId?: string;
|
|
9
|
+
}
|
|
4
10
|
/**
|
|
5
11
|
* @publicApi
|
|
6
12
|
*/
|
|
@@ -9,7 +15,8 @@ export declare class TestingInjector extends Injector {
|
|
|
9
15
|
protected container: NestContainer;
|
|
10
16
|
setMocker(mocker: MockFactory): void;
|
|
11
17
|
setContainer(container: NestContainer): void;
|
|
12
|
-
resolveComponentWrapper<T>(moduleRef: Module, name: any, dependencyContext: InjectorDependencyContext, wrapper: InstanceWrapper<T>,
|
|
13
|
-
resolveComponentHost<T>(moduleRef: Module, instanceWrapper: InstanceWrapper<T>,
|
|
18
|
+
resolveComponentWrapper<T>(moduleRef: Module, name: any, dependencyContext: InjectorDependencyContext, wrapper: InstanceWrapper<T>, resolutionContext?: ResolutionContext, keyOrIndex?: string | number): Promise<InstanceWrapper>;
|
|
19
|
+
resolveComponentHost<T>(moduleRef: Module, instanceWrapper: InstanceWrapper<T>, resolutionContext?: ResolutionContext): Promise<InstanceWrapper>;
|
|
14
20
|
private mockWrapper;
|
|
15
21
|
}
|
|
22
|
+
export {};
|
package/testing-injector.js
CHANGED
|
@@ -11,18 +11,18 @@ export class TestingInjector extends Injector {
|
|
|
11
11
|
setContainer(container) {
|
|
12
12
|
this.container = container;
|
|
13
13
|
}
|
|
14
|
-
async resolveComponentWrapper(moduleRef, name, dependencyContext, wrapper,
|
|
14
|
+
async resolveComponentWrapper(moduleRef, name, dependencyContext, wrapper, resolutionContext = { contextId: STATIC_CONTEXT }, keyOrIndex) {
|
|
15
15
|
try {
|
|
16
|
-
const existingProviderWrapper = await super.resolveComponentWrapper(moduleRef, name, dependencyContext, wrapper,
|
|
16
|
+
const existingProviderWrapper = await super.resolveComponentWrapper(moduleRef, name, dependencyContext, wrapper, resolutionContext, keyOrIndex);
|
|
17
17
|
return existingProviderWrapper;
|
|
18
18
|
}
|
|
19
19
|
catch (err) {
|
|
20
20
|
return this.mockWrapper(err, moduleRef, name, wrapper);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
async resolveComponentHost(moduleRef, instanceWrapper,
|
|
23
|
+
async resolveComponentHost(moduleRef, instanceWrapper, resolutionContext = { contextId: STATIC_CONTEXT }) {
|
|
24
24
|
try {
|
|
25
|
-
const existingProviderWrapper = await super.resolveComponentHost(moduleRef, instanceWrapper,
|
|
25
|
+
const existingProviderWrapper = await super.resolveComponentHost(moduleRef, instanceWrapper, resolutionContext);
|
|
26
26
|
return existingProviderWrapper;
|
|
27
27
|
}
|
|
28
28
|
catch (err) {
|
|
@@ -113,6 +113,7 @@ export class TestingModuleBuilder {
|
|
|
113
113
|
async createInstancesOfDependencies(graphInspector, options) {
|
|
114
114
|
const injector = new TestingInjector({
|
|
115
115
|
preview: options?.preview ?? false,
|
|
116
|
+
snapshot: options?.snapshot ?? false,
|
|
116
117
|
});
|
|
117
118
|
const instanceLoader = new TestingInstanceLoader(this.container, injector, graphInspector);
|
|
118
119
|
await instanceLoader.createInstancesOfDependencies(this.container.getModules(), this.mocker);
|