@grest-ts/testkit-runtime 0.0.14 → 0.0.16

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/README.md +38 -0
  2. package/package.json +2 -5
package/README.md CHANGED
@@ -3,3 +3,41 @@
3
3
  > [Documentation](https://github.com/grest-ts/grest-ts#readme) | [All packages](https://github.com/grest-ts/grest-ts#package-reference)
4
4
  <!-- GREST-TS-BANNER-END -->
5
5
 
6
+ # @grest-ts/testkit-runtime
7
+
8
+ Thin runtime component of `@grest-ts/testkit`. Provides the `@mockable` and `@testable` decorators that you add to your service classes. This package is included in production builds but has **zero effect at runtime** — decorators only activate when a test context is present.
9
+
10
+ You typically don't interact with this package directly beyond applying the decorators.
11
+
12
+ ## `@mockable`
13
+
14
+ Marks a class so its async methods can be mocked or spied on during tests.
15
+
16
+ ```typescript
17
+ import {mockable} from "@grest-ts/testkit-runtime";
18
+
19
+ @mockable
20
+ export class WeatherService {
21
+ async getWeather(city: string): Promise<WeatherData> {
22
+ // real implementation
23
+ }
24
+ }
25
+ ```
26
+
27
+ In production, calls pass through unchanged. During tests, `@grest-ts/testkit` can intercept calls via `mockOf()` and `spyOn()`.
28
+
29
+ ## `@testable`
30
+
31
+ Marks a class so tests can invoke its methods directly via `callOn()`, without going through the full API layer.
32
+
33
+ ```typescript
34
+ import {mockable, testable} from "@grest-ts/testkit-runtime";
35
+
36
+ @testable
37
+ @mockable
38
+ export class WeatherService {
39
+ async getWeather(city: string): Promise<WeatherData> { /* ... */ }
40
+ }
41
+ ```
42
+
43
+ Instances are automatically registered in the service locator on construction, making them accessible to the test runner.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grest-ts/testkit-runtime",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Component testing library runtime code. ",
@@ -43,9 +43,6 @@
43
43
  "node": ">=25"
44
44
  },
45
45
  "dependencies": {
46
- "@grest-ts/locator": "0.0.14"
47
- },
48
- "devDependencies": {
49
- "@grest-ts/x-packager": "0.0.14"
46
+ "@grest-ts/locator": "0.0.16"
50
47
  }
51
48
  }