react-obsidian 0.0.18 → 0.0.19

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 CHANGED
@@ -1,3 +1,5 @@
1
+ [![SWUbanner](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://vshymanskyy.github.io/StandWithUkraine)
2
+
1
3
  # react-obsidian
2
4
  > Dependency injection framework for React and React Native applications
3
5
 
@@ -5,11 +7,10 @@
5
7
  <br>⚠️ <b>Until we hit v1, Obsidian is not semver-compliant and all APIs are subject to change.</b></h5>
6
8
 
7
9
  ## Introduction
8
- Applications are made of objects that communicate with each other. An object can depend on other objects so it can perform its responsibilities. For an object to function properly, its dependencies must be fulfilled when the object is constructed.
9
10
 
10
11
  React Obsidian is a dependency injection framework for React and React Native applications. It allows you to inject dependencies effortlessly into hooks, components or classes. Separating the construction and consumption of dependencies is crucial to maintaining a readable and testable codebase.
11
12
 
12
- React Obsidian is guided by the principles of the Dependency Injection pattern, but does not strictly follow it. We allowed ourselves a degree of freedom when designing the library in order to reduce boilerplate code and reduce library footprint.
13
+ React Obsidian is guided by the principles of the Dependency Injection pattern, but does not strictly follow them. We allowed ourselves a degree of freedom when designing the library in order to reduce boilerplate code and library footprint.
13
14
 
14
15
  * [Installation](https://github.com/wix-incubator/react-obsidian#installation)
15
16
  * [Prerequisites](https://github.com/wix-incubator/react-obsidian#prerequisites)
@@ -24,7 +25,7 @@ React Obsidian is guided by the principles of the Dependency Injection pattern,
24
25
  * [Advance usage](https://github.com/wix-incubator/react-obsidian#advance-usage)
25
26
  * [Accessing props in graphs](https://github.com/wix-incubator/react-obsidian#accessing-props-in-graphs)
26
27
  * [Singleton graphs and providers](https://github.com/wix-incubator/react-obsidian#singleton-graphs-and-providers)
27
- * [Graph middlewares](https://github.com/wix-incubator/react-obsidian#graph-middlewares)
28
+ * [Graph middleware](https://github.com/wix-incubator/react-obsidian#graph-middleware)
28
29
 
29
30
 
30
31
 
@@ -49,7 +50,7 @@ In the `ApplicationGraph` example below, we declare two dependencies:
49
50
 
50
51
  Both functions are annotated by the `@Provides()` annotation. This signals Obsidian that the results of these functions are provided by the graph and can be injected.
51
52
 
52
- Notice how the biLogger function receives an `httpClient` as an argument. This means that `biLogger` has a dependency on `httpClient`. Obsidian will create an `httpClient` when `biLogger` is injected.
53
+ Notice how the biLogger function receives an `httpClient` as an argument. This means that `biLogger` is dependent on `httpClient`. Obsidian will create an `httpClient` when `biLogger` is injected.
53
54
 
54
55
  ``` typescript
55
56
  @Singleton() @Graph()
@@ -106,7 +107,7 @@ const useButtonClick = ({ biLogger }: UseButtonPressProps): UseButtonPress => {
106
107
  // Dependencies are injected from ApplicationGraph
107
108
  export default injectHook(usePress, ApplicationGraph);
108
109
 
109
- // Now that exported the injected hook, we can use it in a component without needed so provide it's dependencies manually
110
+ // Now that we exported the injected hook, we can use it in a component without the needed so provide its dependencies manually
110
111
  const Component = () => (
111
112
  // No need to specify dependencies as they are injected automatically
112
113
  const { onClick } = useButtonClick();
@@ -139,7 +140,7 @@ class Presenter {
139
140
  }
140
141
  ```
141
142
 
142
- TypeScript's compiler won't let you construct the class without providing the argument `biLogger` as it's not optional.
143
+ The TypeScript compiler won't let you construct the class without providing the `biLogger` argument as it's not optional.
143
144
  If you want to be able to instantiate the class yourself without providing arguments, you'll also need to declare a constructor overload that receives optional arguments.
144
145
 
145
146
  ```typescript
@@ -160,11 +161,11 @@ Dependencies can also be obtained by accessing the graph that provides them.
160
161
  Obsidian.obtain(ApplicationGraph).biLogger();
161
162
  ```
162
163
 
163
- > Note: While the function that provides the `biLogger` accepts an argument of type `HttpClient`, when obtaining dependencies directly from the graph, we don't provide dependencies ourselves as they are resolved by Obsidian.
164
+ > Note: While the function that provides the `biLogger` accepts an argument of type `HttpClient`, we don't provide dependencies ourselves when obtaining dependencies directly from the graph, as they are resolved by Obsidian.
164
165
 
165
- ## Advance usage
166
+ ## Advanced usage
166
167
  ### Accessing props in graphs
167
- If a graph is instantiated in order to inject a component, then it receives the component's props in the constructor.
168
+ If a graph is instantiated in order to inject a component, then it will receive the component's props in the constructor.
168
169
  ```typescript
169
170
  @Graph()
170
171
  class ProfileScreenGraph extends ObjectGraph<ProfileScreenProps> {
@@ -181,8 +182,9 @@ class ProfileScreenGraph extends ObjectGraph<ProfileScreenProps> {
181
182
  }
182
183
  }
183
184
  ```
185
+
184
186
  ### Singleton graphs and providers
185
- Graphs and Providers can be marked as singletons with the `@Singleton` decorator. When a graph is marked as a singleton, when an instance of that graph is requested, Obsidian will reuse the existing instance. Graphs that are not annotated with the `@Singleton` decorator will be instantiated each time they are needed for injection.
187
+ Graphs and Providers can be marked as singletons with the `@Singleton` decorator. If a graph is marked as a singleton, when an instance of such graph is requested, Obsidian will reuse the existing instance. Graphs that are not annotated with the `@Singleton` decorator will be instantiated each time they are needed for injection.
186
188
 
187
189
  Singleton providers are shared between all instances of a graph.
188
190
 
@@ -211,16 +213,17 @@ class ApplicationGraph {
211
213
  }
212
214
  }
213
215
  ```
214
- ### Graph middlewares
215
- When working on large scale applications, a need to hook into various low level operations often arises. Obsidian lets you hook into the graph creation process by adding middlewares.
216
216
 
217
- Middlewares are invoked in LIFO order and can be used for various purposes:
218
- 1. Create a graph yourself instead of letting Obsidian instantiate it.
217
+ ### Graph middleware
218
+ When working on large scale applications, we often need to to hook into various low level operations. Obsidian lets you hook into the graph creation process by adding middleware(s).
219
+
220
+ Those middleware are invoked in LIFO order and can be used for various purposes:
221
+ 1. Create a graph yourself instead of letting Obsidian to instantiate it.
219
222
  2. Add logging to graph creation.
220
223
  3. Handle errors when Obsidian instantiates graphs.
221
224
  4. Replace graphs with mocks for testing purposes.
222
225
 
223
- Middlewares follow the Chain of Responsibility pattern and therefor must always return a graph, either by creating one explicitly or by returning the instance created by another member in the resolve chain.
226
+ Middleware follow the Chain of Responsibility pattern and therefore must always return a graph, either by creating one explicitly or by returning the instance created by another member in the resolve chain.
224
227
 
225
228
  #### Adding a logging middleware
226
229
  The following example demonstrates how to add a middleware that's used for logging purposes.
@@ -237,6 +240,10 @@ const loggingMiddleware = new class extends GraphMiddleware {
237
240
  }();
238
241
  Obsidian.addGraphMiddleware(loggingMiddleware);
239
242
  ```
243
+
244
+ #### Clear graphs
245
+ Graphs can be cleared by invoking `Obsidian.clearGraphs()`. This is useful in tests or when you need to reset the system to it's original state, for example when a user logs out.
246
+
240
247
  ## Prerequisites
241
248
  Obsidian is highly opinionated and is developed with a specific environment in mind. Therefore, it has a few prerequisites for projects that want to integrate it.
242
249
 
@@ -263,7 +270,7 @@ Add the following options to your `tsconfig.json` file.
263
270
  ```
264
271
 
265
272
  ### Babel
266
- Obsidian relies on reflection to resolve dependencies. Production code is typically mangled to reduce bundle size. This means that some names Obsidian expects are changed during the mangling process. To workaround this, Obsidian persists the names of methods annotated with the `@Provides` decorator with a Babel transformer.
273
+ Obsidian relies on reflection to resolve dependencies. Production code is typically mangled to reduce bundle size. This means that some names Obsidian expects are changed during the mangling process. To work around this, Obsidian persists the names of methods annotated with the `@Provides` decorator with a Babel transformer.
267
274
 
268
275
  ### Add Obsidian's babel transformer
269
276
  Add the transformer to the list of plugins in your `.babel` file.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=resetGraphs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resetGraphs.d.ts","sourceRoot":"","sources":["../resetGraphs.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var src_1 = require("./src");
4
+ beforeEach(function () {
5
+ src_1.Obsidian.clearGraphs();
6
+ });
7
+ //# sourceMappingURL=resetGraphs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resetGraphs.js","sourceRoot":"","sources":["../resetGraphs.ts"],"names":[],"mappings":";;AAAA,6BAAiC;AAEjC,UAAU,CAAC;IACT,cAAQ,CAAC,WAAW,EAAE,CAAC;AACzB,CAAC,CAAC,CAAC"}
@@ -6,5 +6,6 @@ export default class Obsidian {
6
6
  inject<T extends object>(target: T, graph?: ObjectGraph): object;
7
7
  addGraphMiddleware(middleware: GraphMiddleware): void;
8
8
  clearGraphMiddlewares(): void;
9
+ clearGraphs(): void;
9
10
  }
10
11
  //# sourceMappingURL=Obsidian.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Obsidian.d.ts","sourceRoot":"","sources":["../../src/Obsidian.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAGnE,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC3B,MAAM,CAAC,CAAC,SAAS,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,EACtC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,KAAK,CAAC,EAAE,CAAC,GACR,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;IAI1C,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,WAAW;IAIvD,kBAAkB,CAAC,UAAU,EAAE,eAAe;IAI9C,qBAAqB;CAGtB"}
1
+ {"version":3,"file":"Obsidian.d.ts","sourceRoot":"","sources":["../../src/Obsidian.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAGnE,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC3B,MAAM,CAAC,CAAC,SAAS,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,EACtC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,KAAK,CAAC,EAAE,CAAC,GACR,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;IAI1C,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,WAAW;IAIvD,kBAAkB,CAAC,UAAU,EAAE,eAAe;IAI9C,qBAAqB;IAIrB,WAAW;CAIZ"}
@@ -20,6 +20,10 @@ var Obsidian = /** @class */ (function () {
20
20
  Obsidian.prototype.clearGraphMiddlewares = function () {
21
21
  GraphRegistry_1.default.clearGraphMiddlewares();
22
22
  };
23
+ Obsidian.prototype.clearGraphs = function () {
24
+ GraphRegistry_1.default.clearGraphMiddlewares();
25
+ GraphRegistry_1.default.clearAll();
26
+ };
23
27
  return Obsidian;
24
28
  }());
25
29
  exports.default = Obsidian;
@@ -1 +1 @@
1
- {"version":3,"file":"Obsidian.js","sourceRoot":"","sources":["../../src/Obsidian.ts"],"names":[],"mappings":";;;;;AAAA,iFAA2D;AAI3D,gFAA0D;AAE1D;IAAA;IAmBA,CAAC;IAlBC,yBAAM,GAAN,UACE,KAAuB,EACvB,KAAS;QAET,OAAO,uBAAa,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAiC,CAAC;IAC7E,CAAC;IAED,yBAAM,GAAN,UAAyB,MAAS,EAAE,KAAmB;QACrD,OAAO,sBAAY,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;IAED,qCAAkB,GAAlB,UAAmB,UAA2B;QAC5C,uBAAa,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAC/C,CAAC;IAED,wCAAqB,GAArB;QACE,uBAAa,CAAC,qBAAqB,EAAE,CAAC;IACxC,CAAC;IACH,eAAC;AAAD,CAAC,AAnBD,IAmBC"}
1
+ {"version":3,"file":"Obsidian.js","sourceRoot":"","sources":["../../src/Obsidian.ts"],"names":[],"mappings":";;;;;AAAA,iFAA2D;AAI3D,gFAA0D;AAE1D;IAAA;IAwBA,CAAC;IAvBC,yBAAM,GAAN,UACE,KAAuB,EACvB,KAAS;QAET,OAAO,uBAAa,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAiC,CAAC;IAC7E,CAAC;IAED,yBAAM,GAAN,UAAyB,MAAS,EAAE,KAAmB;QACrD,OAAO,sBAAY,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;IAED,qCAAkB,GAAlB,UAAmB,UAA2B;QAC5C,uBAAa,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAC/C,CAAC;IAED,wCAAqB,GAArB;QACE,uBAAa,CAAC,qBAAqB,EAAE,CAAC;IACxC,CAAC;IAED,8BAAW,GAAX;QACE,uBAAa,CAAC,qBAAqB,EAAE,CAAC;QACtC,uBAAa,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IACH,eAAC;AAAD,CAAC,AAxBD,IAwBC"}
@@ -18,7 +18,7 @@ export declare class GraphRegistry {
18
18
  clear(graph: Graph): void;
19
19
  addGraphMiddleware(middleware: Middleware<Graph>): void;
20
20
  clearGraphMiddlewares(): void;
21
- reset(): void;
21
+ clearAll(): void;
22
22
  }
23
23
  declare const _default: GraphRegistry;
24
24
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"GraphRegistry.d.ts","sourceRoot":"","sources":["../../../../src/graph/registry/GraphRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAA+C;IACrF,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAA0C;IAChF,OAAO,CAAC,QAAQ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AK,CAAC,EAAE,SAAS,GAAE,aAAa,CAAC,KAAK,CAAC,EAAO;IAIlF,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,EAAE;IAMnC,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK;IAIrC,OAAO,CAAC,CAAC,SAAS,KAAK,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,CAAC;IASjE,OAAO,CAAC,GAAG;IAIX,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,GAAG;IAQX,OAAO,CAAC,WAAW;IAInB,KAAK,CAAC,KAAK,EAAE,KAAK;IAOlB,kBAAkB,CAAC,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC;IAIhD,qBAAqB;IAIrB,QAAQ;CAKT;;AAED,wBAAmC"}
@@ -65,7 +65,7 @@ var GraphRegistry = /** @class */ (function () {
65
65
  GraphRegistry.prototype.clearGraphMiddlewares = function () {
66
66
  this.graphMiddlewares.clear();
67
67
  };
68
- GraphRegistry.prototype.reset = function () {
68
+ GraphRegistry.prototype.clearAll = function () {
69
69
  this.instanceToConstructor.clear();
70
70
  this.constructorToInstance.clear();
71
71
  this.nameToInstance.clear();
@@ -1 +1 @@
1
- {"version":3,"file":"GraphRegistry.js","sourceRoot":"","sources":["../../../../src/graph/registry/GraphRegistry.ts"],"names":[],"mappings":";;;;;;AAGA,gFAA0D;AAE1D;IAAA;QACmB,0BAAqB,GAAG,IAAI,GAAG,EAAoC,CAAC;QACpE,0BAAqB,GAAG,IAAI,GAAG,EAA+B,CAAC;QAC/D,mBAAc,GAAG,IAAI,GAAG,EAAiB,CAAC;QAC1C,qBAAgB,GAAG,IAAI,GAAG,EAAmD,CAAC;QAC9E,qBAAgB,GAAG,IAAI,8BAAoB,EAAE,CAAC;IAiEjE,CAAC;IA/DC,gCAAQ,GAAR,UAAS,WAAiC,EAAE,SAAsC;QAAtC,0BAAA,EAAA,cAAsC;QACh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EAAE,GAAG,KAAK,WAAW,CAAC,CAAC;CAY/G;AAED,eAAO,MAAM,OAAO,SAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../testkit/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,cAAM,OAAO;IACJ,UAAU,CAAC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,WAAW,CAAC,CAAC;CAY/G;AAED,eAAO,MAAM,OAAO,SAAgB,CAAC"}
@@ -22,10 +22,6 @@ exports.testKit = void 0;
22
22
  var ObjectGraph_1 = require("../src/graph/ObjectGraph");
23
23
  var GraphMiddleware_1 = require("../src/graph/registry/GraphMiddleware");
24
24
  var GraphRegistry_1 = __importDefault(require("../src/graph/registry/GraphRegistry"));
25
- beforeEach(function () {
26
- GraphRegistry_1.default.clearGraphMiddlewares();
27
- GraphRegistry_1.default.reset();
28
- });
29
25
  var TestKit = /** @class */ (function () {
30
26
  function TestKit() {
31
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../testkit/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,wDAAgE;AAChE,yEAAwE;AAExE,sFAAgE;AAEhE,UAAU,CAAC;IACT,uBAAa,CAAC,qBAAqB,EAAE,CAAC;IACtC,uBAAa,CAAC,KAAK,EAAE,CAAC;AACxB,CAAC,CAAC,CAAC;AAEH;IAAA;IAaA,CAAC;IAZQ,4BAAU,GAAjB,UAAkB,gBAA4F;QAC5G,IAAM,eAAe,GAAG;YAAkB,2BAAe;YAA7B;;YAQ5B,CAAC;YAPC,yBAAO,GAAP,UAAe,YAA+B,EAAE,KAAiC,EAAE,KAAa;gBAC9F,IAAI,gBAAgB,CAAC,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AC;QAAD,CAAC,AAR2B,CAAc,iCAAe,IAQtD,CAAC;QACJ,uBAAa,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACpD,CAAC;IACH,cAAC;AAAD,CAAC,AAbD,IAaC;AAEY,QAAA,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC"}
@@ -1 +1,4 @@
1
1
  require('setimmediate');
2
+ require('reflect-metadata');
3
+ require('./resetGraphs');
4
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-obsidian",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "description": "Dependency injection framework for React and React Native applications",
5
5
  "scripts": {
6
6
  "prepack": "npm run lint && tsc --project tsconfig.prod.json",
package/resetGraphs.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { Obsidian } from './src';
2
+
3
+ beforeEach(() => {
4
+ Obsidian.clearGraphs();
5
+ });
package/src/Obsidian.ts CHANGED
@@ -23,4 +23,9 @@ export default class Obsidian {
23
23
  clearGraphMiddlewares() {
24
24
  graphRegistry.clearGraphMiddlewares();
25
25
  }
26
+
27
+ clearGraphs() {
28
+ graphRegistry.clearGraphMiddlewares();
29
+ graphRegistry.clearAll();
30
+ }
26
31
  }
@@ -68,7 +68,7 @@ export class GraphRegistry {
68
68
  this.graphMiddlewares.clear();
69
69
  }
70
70
 
71
- reset() {
71
+ clearAll() {
72
72
  this.instanceToConstructor.clear();
73
73
  this.constructorToInstance.clear();
74
74
  this.nameToInstance.clear();
package/testkit/index.ts CHANGED
@@ -4,11 +4,6 @@ import { GraphMiddleware } from '../src/graph/registry/GraphMiddleware';
4
4
  import { Constructable } from '../src/types';
5
5
  import graphRegistry from '../src/graph/registry/GraphRegistry';
6
6
 
7
- beforeEach(() => {
8
- graphRegistry.clearGraphMiddlewares();
9
- graphRegistry.reset();
10
- });
11
-
12
7
  class TestKit {
13
8
  public mockGraphs(graphNameToGraph: Record<string, Constructable<ObjectGraph> | ((props: any) => ObjectGraph)>) {
14
9
  const graphMiddleware = new class extends GraphMiddleware {
@@ -2,7 +2,8 @@
2
2
  "include": [
3
3
  "src/**/*",
4
4
  "transformers/**/*",
5
- "test/**/*"
5
+ "test/**/*",
6
+ "./resetGraphs.ts"
6
7
  ],
7
8
  "exclude": [
8
9
  "node_modules",
package/jest.setup.ts DELETED
@@ -1 +0,0 @@
1
- import 'reflect-metadata';