@kensio/yulin-aws-simulation 1.15.0 → 1.17.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,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://anthropic.com/claude-code/plugin.schema.json",
3
3
  "name": "yulin-aws-simulation",
4
- "version": "1.15.0",
4
+ "version": "1.17.0",
5
5
  "description": "How to test AWS code well with the @kensio/yulin in-process simulator.",
6
6
  "author": {
7
7
  "name": "Kensio Software",
package/README.md CHANGED
@@ -67,6 +67,12 @@ ambiguous with the suffix Secrets Manager appends to an ARN and advised against
67
67
  already reached production. It caught a wrongly computed Cognito `SECRET_HASH` the stub had happily
68
68
  accepted.
69
69
 
70
+ **Drive requests into the simulation with `SimAwsHttp`.** Reading state back covers the resources.
71
+ `http.fetch("https://www.example.test/docs/x")` covers the path through them, with nothing listening
72
+ and no port to add. One request resolves the hostname through simulated Route 53, finds the
73
+ Distribution its alias records point at, and runs the deployed CloudFront Function at
74
+ viewer-request. A template assertion over the same stack passes with every Route 53 record missing.
75
+
70
76
  **Match service errors by `name`.** The SDK exports its exception classes, which invites the wrong
71
77
  check. `instanceof` holds only while exactly one copy of the SDK is in play. It passes in production
72
78
  and fails against the simulator. `name` is what the wire carries, and is the check that is right in
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kensio/yulin-aws-simulation",
3
- "version": "1.15.0",
3
+ "version": "1.17.0",
4
4
  "description": "How to test AWS code well with the @kensio/yulin in-process simulator.",
5
5
  "keywords": [
6
6
  "agent-skills",
@@ -1,19 +1,25 @@
1
1
  ---
2
2
  name: yulin-aws-simulation
3
- description: Use the @kensio/yulin in-process AWS simulator well when testing AWS code, using it directly rather than building a harness around it, driving tests, local dev and production from one synthesized CDK template, deploying a whole cdk.out cloud assembly, intercepting SDK clients with SimSdk, controlling simulated time, matching service errors by name, and handling properties Yulin refuses to simulate. Use when writing or reviewing tests that touch AWS, when replacing aws-sdk-client-mock or hand-rolled AWS stubs, when a CDK stack needs testing, when test setup around Yulin is growing helper classes or wrapper functions, and when Yulin refuses a template property or an SDK command.
3
+ description: Use the @kensio/yulin in-process AWS simulator well when testing AWS code, using it directly rather than building a harness around it, driving tests, local dev and production from one synthesized CDK template, deploying a whole cdk.out cloud assembly, intercepting SDK clients with SimSdk, driving HTTP requests into the simulation with SimAwsHttp, controlling simulated time, matching service errors by name, and handling properties Yulin refuses to simulate. Use when writing or reviewing tests that touch AWS, when replacing aws-sdk-client-mock or hand-rolled AWS stubs, when a CDK stack needs testing, when a CloudFront Distribution, its DNS records or its certificate need testing, when test setup around Yulin is growing helper classes or wrapper functions, and when Yulin refuses a template property or an SDK command.
4
4
  license: Apache-2.0
5
5
  metadata:
6
- version: "1.15.0"
6
+ version: "1.17.0"
7
7
  ---
8
8
 
9
9
  # Testing with Yulin
10
10
 
11
11
  [Yulin](https://yulinsim.dev/) (`@kensio/yulin`) simulates AWS in process, in memory, with no
12
- network and no AWS account. This skill is how to use it well. For the API read
13
- [yulinsim.dev/llms.txt](https://yulinsim.dev/llms.txt), one markdown page per guide and per
14
- simulated service (drop the `llms.txt` for HTML, or read `docs/` in the repository). It serves
15
- `isolated-testing-style`, the general argument for simulation over stubs. Each rule says what it
16
- buys, and a case that does not want that trade can go the other way knowingly.
12
+ network and no AWS account. This skill is how to use it well. It serves `isolated-testing-style`,
13
+ the general argument for simulation over stubs. Each rule says what it buys, and a case that does
14
+ not want that trade can go the other way knowingly.
15
+
16
+ For the API read `node_modules/@kensio/yulin/llms.txt`. It indexes the 45 markdown pages beside it
17
+ under `node_modules/@kensio/yulin/docs/`, one per simulated service and per feature guide,
18
+ documenting the version installed. Open the page it names for the service in hand and grep it for
19
+ the operation or property, since Cognito runs to 210 KB with DynamoDB and Lambda close behind. Where
20
+ the package is absent, or predates the 1.20.x that started carrying it,
21
+ [yulinsim.dev/llms.txt](https://yulinsim.dev/llms.txt) has the same index for the current release
22
+ (drop the `llms.txt` for HTML).
17
23
 
18
24
  ## Use what Yulin already gives you
19
25
 
@@ -213,6 +219,33 @@ scope has), so look on the other scope before concluding a service is missing. E
213
219
  plain `{ input: { ... } }` in place of a Command object. An assertion can therefore read a service
214
220
  back without adding an `@aws-sdk/client-*` package the production code has no use for.
215
221
 
222
+ ## Drive requests into the simulation
223
+
224
+ Reading state back covers the resources. `SimAwsHttp` from `@kensio/yulin/serve` covers the path
225
+ through them, by sending a request into the environment with nothing listening. It takes what the
226
+ global `fetch` takes and answers with a `Response`:
227
+
228
+ ```typescript
229
+ const http = new SimAwsHttp({ simAws });
230
+ const response = await http.fetch("https://www.example.test/docs/x?a=1", { redirect: "manual" });
231
+
232
+ // Then the apex redirect the CloudFront Function performs has been applied.
233
+ expect(response.status).toBe(301);
234
+ expect(response.headers.get("location")).toBe("https://example.test/docs/x?a=1");
235
+ ```
236
+
237
+ A hostname simulated Route 53 answers for is requested by its own name, with no port to add and no
238
+ `localUrl(...)` adapting (an `https` URL works with no certificate set up for it). That one request
239
+ resolves the hostname, finds the Distribution its alias records point at, and runs the deployed
240
+ CloudFront Function at viewer-request. The certificate, the Hosted Zone records, the Distribution's
241
+ aliases and the function are covered together. A template assertion over the same stack passes with
242
+ every Route 53 record missing.
243
+
244
+ Reach for `serveSimAws` when the request comes from outside the process, such as a browser, `curl`
245
+ or an SDK client pointed at a local endpoint. Both go through the same routing and service code, and
246
+ `SimAwsHttp` leaves parallel test files no port to collide over. See
247
+ [the serving docs](https://yulinsim.dev/serve/) for the API.
248
+
216
249
  ## Match service errors by name
217
250
 
218
251
  ```typescript