@nestjs/testing 9.3.0-beta.3 → 9.3.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.
@@ -1,2 +1,2 @@
1
1
  import { InstanceToken } from '@nestjs/core/injector/module';
2
- export declare type MockFactory = (token?: InstanceToken) => any;
2
+ export type MockFactory = (token?: InstanceToken) => any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/testing",
3
- "version": "9.3.0-beta.3",
3
+ "version": "9.3.0",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@testing)",
5
5
  "author": "Kamil Mysliwiec",
6
6
  "license": "MIT",
@@ -1,5 +1,4 @@
1
- import { LoggerService } from '@nestjs/common';
2
- import { ModuleMetadata } from '@nestjs/common/interfaces';
1
+ import { LoggerService, ModuleMetadata } from '@nestjs/common';
3
2
  import { NestApplicationContextOptions } from '@nestjs/common/interfaces/nest-application-context-options.interface';
4
3
  import { MetadataScanner } from '@nestjs/core/metadata-scanner';
5
4
  import { MockFactory, OverrideBy } from './interfaces';
@@ -26,6 +25,7 @@ export declare class TestingModuleBuilder {
26
25
  private createOverrideByBuilder;
27
26
  private applyOverloadsMap;
28
27
  private getRootModule;
28
+ private createInstancesOfDependencies;
29
29
  private createModule;
30
30
  private applyLogger;
31
31
  }
@@ -6,6 +6,7 @@ const application_config_1 = require("@nestjs/core/application-config");
6
6
  const container_1 = require("@nestjs/core/injector/container");
7
7
  const graph_inspector_1 = require("@nestjs/core/inspector/graph-inspector");
8
8
  const noop_graph_inspector_1 = require("@nestjs/core/inspector/noop-graph-inspector");
9
+ const uuid_factory_1 = require("@nestjs/core/inspector/uuid-factory");
9
10
  const scanner_1 = require("@nestjs/core/scanner");
10
11
  const testing_logger_service_1 = require("./services/testing-logger.service");
11
12
  const testing_injector_1 = require("./testing-injector");
@@ -45,14 +46,19 @@ class TestingModuleBuilder {
45
46
  }
46
47
  async compile(options = {}) {
47
48
  this.applyLogger();
48
- const graphInspector = (options === null || options === void 0 ? void 0 : options.snapshot)
49
- ? new graph_inspector_1.GraphInspector(this.container)
50
- : noop_graph_inspector_1.NoopGraphInspector;
49
+ let graphInspector;
50
+ if (options === null || options === void 0 ? void 0 : options.snapshot) {
51
+ graphInspector = new graph_inspector_1.GraphInspector(this.container);
52
+ uuid_factory_1.UuidFactory.mode = uuid_factory_1.UuidFactoryMode.Deterministic;
53
+ }
54
+ else {
55
+ graphInspector = noop_graph_inspector_1.NoopGraphInspector;
56
+ uuid_factory_1.UuidFactory.mode = uuid_factory_1.UuidFactoryMode.Random;
57
+ }
51
58
  const scanner = new scanner_1.DependenciesScanner(this.container, this.metadataScanner, graphInspector, this.applicationConfig);
52
59
  await scanner.scan(this.module);
53
60
  this.applyOverloadsMap();
54
- const instanceLoader = new testing_instance_loader_1.TestingInstanceLoader(this.container, this.injector, graphInspector);
55
- await instanceLoader.createInstancesOfDependencies(this.container.getModules(), this.mocker);
61
+ await this.createInstancesOfDependencies(graphInspector);
56
62
  scanner.applyApplicationProviders();
57
63
  const root = this.getRootModule();
58
64
  return new testing_module_1.TestingModule(this.container, graphInspector, root, this.applicationConfig);
@@ -80,6 +86,10 @@ class TestingModuleBuilder {
80
86
  const modules = this.container.getModules().values();
81
87
  return modules.next().value;
82
88
  }
89
+ async createInstancesOfDependencies(graphInspector) {
90
+ const instanceLoader = new testing_instance_loader_1.TestingInstanceLoader(this.container, this.injector, graphInspector);
91
+ await instanceLoader.createInstancesOfDependencies(this.container.getModules(), this.mocker);
92
+ }
83
93
  createModule(metadata) {
84
94
  class RootTestModule {
85
95
  }