@grest-ts/testkit 0.0.6 → 0.0.7

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 (46) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +413 -413
  3. package/dist/src/runner/isolated-loader.mjs +91 -91
  4. package/dist/src/runner/worker-loader.mjs +49 -49
  5. package/dist/tsconfig.publish.tsbuildinfo +1 -1
  6. package/package.json +12 -12
  7. package/src/GGBundleTest.ts +89 -89
  8. package/src/GGTest.ts +318 -318
  9. package/src/GGTestContext.ts +74 -74
  10. package/src/GGTestRunner.ts +308 -308
  11. package/src/GGTestRuntime.ts +265 -265
  12. package/src/GGTestRuntimeWorker.ts +159 -159
  13. package/src/GGTestSharedRef.ts +116 -116
  14. package/src/GGTestkitExtensionsDiscovery.ts +26 -26
  15. package/src/IGGLocalDiscoveryServer.ts +16 -16
  16. package/src/callOn/GGCallOnSelector.ts +61 -61
  17. package/src/callOn/GGContractClass.implement.ts +43 -43
  18. package/src/callOn/GGTestActionForLocatorOnCall.ts +134 -134
  19. package/src/callOn/TestableIPC.ts +81 -81
  20. package/src/callOn/callOn.ts +224 -224
  21. package/src/callOn/registerOnCallHandler.ts +123 -123
  22. package/src/index-node.ts +64 -64
  23. package/src/mockable/GGMockable.ts +22 -22
  24. package/src/mockable/GGMockableCall.ts +45 -45
  25. package/src/mockable/GGMockableIPC.ts +20 -20
  26. package/src/mockable/GGMockableInterceptor.ts +44 -44
  27. package/src/mockable/GGMockableInterceptorsServer.ts +69 -69
  28. package/src/mockable/mockable.ts +71 -71
  29. package/src/runner/InlineRunner.ts +47 -47
  30. package/src/runner/IsolatedRunner.ts +179 -179
  31. package/src/runner/RuntimeRunner.ts +15 -15
  32. package/src/runner/WorkerRunner.ts +179 -179
  33. package/src/runner/isolated-loader.mjs +91 -91
  34. package/src/runner/worker-loader.mjs +49 -49
  35. package/src/testers/GGCallInterceptor.ts +224 -224
  36. package/src/testers/GGMockWith.ts +92 -92
  37. package/src/testers/GGSpyWith.ts +115 -115
  38. package/src/testers/GGTestAction.ts +332 -332
  39. package/src/testers/GGTestComponent.ts +16 -16
  40. package/src/testers/GGTestSelector.ts +223 -223
  41. package/src/testers/IGGTestInterceptor.ts +10 -10
  42. package/src/testers/IGGTestWith.ts +15 -15
  43. package/src/testers/RuntimeSelector.ts +151 -151
  44. package/src/utils/GGExpectations.ts +78 -78
  45. package/src/utils/GGTestError.ts +36 -36
  46. package/src/utils/captureStack.ts +53 -53
@@ -1,74 +1,74 @@
1
- import {GGContext} from "@grest-ts/context";
2
- import {callOn, callOnCollection, GGTestCallOn, GGTestCallOnCollection} from "./callOn/callOn";
3
-
4
- // Note: beforeAll, beforeEach, afterEach, afterAll are vitest globals
5
- // Do NOT import them directly - it breaks worker threads that load this module
6
-
7
- // ============================================================================
8
- // Test Collection Types
9
- // ============================================================================
10
-
11
- export class GGTestContext extends GGContext {
12
-
13
-
14
- public resetAfterEach(): this {
15
- afterEach(() => {
16
- this.reset();
17
- });
18
- return this;
19
- }
20
-
21
- /**
22
- * Register APIs and services for testing.
23
- * Returns `this` merged with test clients for all registered items.
24
- *
25
- * @example
26
- * const alice = new GGTestContext("alice")
27
- * .apisV2({
28
- * chain: ChainApi, // HTTP API → test client
29
- * services: {
30
- * weather: WeatherService // Service class → testable access
31
- * }
32
- * });
33
- *
34
- * alice.chain.getWeather({...}) // HTTP test client
35
- * alice.services.weather.getWeather({...}) // Testable service
36
- */
37
- public apis<T extends object>(apis: T): this & GGTestCallOnCollection<T> {
38
- Object.assign(this, callOnCollection(apis, this));
39
- return this as this & GGTestCallOnCollection<T>;
40
- }
41
-
42
- /**
43
- * Call a method on an API or service within this context.
44
- * Creates and caches test clients/proxies for reuse.
45
- *
46
- * @example
47
- * alice.callOn(ChainApi).getWeather({city: "NYC"})
48
- * alice.callOn(WeatherService).getWeather("NYC")
49
- */
50
- public callOn<T extends object>(target: T): GGTestCallOn<T> {
51
- return callOn(target, this)
52
- }
53
-
54
- public beforeAll(callback: () => void): this {
55
- beforeAll(() => this.run(callback));
56
- return this;
57
- }
58
-
59
- public beforeEach(callback: () => void): this {
60
- beforeEach(() => this.run(callback));
61
- return this;
62
- }
63
-
64
- public afterEach(callback: () => void): this {
65
- afterEach(() => this.run(callback));
66
- return this;
67
- }
68
-
69
- public afterAll(callback: () => void): this {
70
- afterAll(() => this.run(callback));
71
- return this;
72
- }
73
- }
74
-
1
+ import {GGContext} from "@grest-ts/context";
2
+ import {callOn, callOnCollection, GGTestCallOn, GGTestCallOnCollection} from "./callOn/callOn";
3
+
4
+ // Note: beforeAll, beforeEach, afterEach, afterAll are vitest globals
5
+ // Do NOT import them directly - it breaks worker threads that load this module
6
+
7
+ // ============================================================================
8
+ // Test Collection Types
9
+ // ============================================================================
10
+
11
+ export class GGTestContext extends GGContext {
12
+
13
+
14
+ public resetAfterEach(): this {
15
+ afterEach(() => {
16
+ this.reset();
17
+ });
18
+ return this;
19
+ }
20
+
21
+ /**
22
+ * Register APIs and services for testing.
23
+ * Returns `this` merged with test clients for all registered items.
24
+ *
25
+ * @example
26
+ * const alice = new GGTestContext("alice")
27
+ * .apisV2({
28
+ * chain: ChainApi, // HTTP API → test client
29
+ * services: {
30
+ * weather: WeatherService // Service class → testable access
31
+ * }
32
+ * });
33
+ *
34
+ * alice.chain.getWeather({...}) // HTTP test client
35
+ * alice.services.weather.getWeather({...}) // Testable service
36
+ */
37
+ public apis<T extends object>(apis: T): this & GGTestCallOnCollection<T> {
38
+ Object.assign(this, callOnCollection(apis, this));
39
+ return this as this & GGTestCallOnCollection<T>;
40
+ }
41
+
42
+ /**
43
+ * Call a method on an API or service within this context.
44
+ * Creates and caches test clients/proxies for reuse.
45
+ *
46
+ * @example
47
+ * alice.callOn(ChainApi).getWeather({city: "NYC"})
48
+ * alice.callOn(WeatherService).getWeather("NYC")
49
+ */
50
+ public callOn<T extends object>(target: T): GGTestCallOn<T> {
51
+ return callOn(target, this)
52
+ }
53
+
54
+ public beforeAll(callback: () => void): this {
55
+ beforeAll(() => this.run(callback));
56
+ return this;
57
+ }
58
+
59
+ public beforeEach(callback: () => void): this {
60
+ beforeEach(() => this.run(callback));
61
+ return this;
62
+ }
63
+
64
+ public afterEach(callback: () => void): this {
65
+ afterEach(() => this.run(callback));
66
+ return this;
67
+ }
68
+
69
+ public afterAll(callback: () => void): this {
70
+ afterAll(() => this.run(callback));
71
+ return this;
72
+ }
73
+ }
74
+