Skip to content

Commit 822c995

Browse files
authored
test(clients): enable snapshots for small subset of clients (#7790)
1 parent cd1d49d commit 822c995

File tree

2,221 files changed

+89546
-78
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,221 files changed

+89546
-78
lines changed

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ test-protocols: bundles
4141
yarn g:vitest run -c vitest.config.protocols.integ.mts
4242

4343
snapshot-compare:
44-
SNAPSHOT_MODE=compare yarn g:vitest run -c vitest.config.snapshots.integ.mts
44+
NODE_OPTIONS='--max-old-space-size=8192' SNAPSHOT_MODE=compare \
45+
yarn g:vitest run -c vitest.config.snapshots.integ.mts
4546

4647
snapshot-write:
47-
SNAPSHOT_MODE=write yarn g:vitest run -c vitest.config.snapshots.integ.mts
48+
NODE_OPTIONS='--max-old-space-size=8192' SNAPSHOT_MODE=write \
49+
yarn g:vitest run -c vitest.config.snapshots.integ.mts
4850

4951
test-schema: bundles
5052
yarn g:vitest run -c vitest.config.protocols-schema.integ.mts

clients/client-appconfigdata/package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
"clean": "premove dist-cjs dist-es dist-types tsconfig.cjs.tsbuildinfo tsconfig.es.tsbuildinfo tsconfig.types.tsbuildinfo",
1313
"extract:docs": "api-extractor run --local",
1414
"generate:client": "node ../../scripts/generate-clients/single-service --solo appconfigdata",
15-
"test:index": "tsc --noEmit ./test/index-types.ts && node ./test/index-objects.spec.mjs"
15+
"test": "yarn g:vitest run --passWithNoTests",
16+
"test:index": "tsc --noEmit ./test/index-types.ts && node ./test/index-objects.spec.mjs",
17+
"test:integration": "yarn g:vitest run --passWithNoTests -c vitest.config.integ.mts",
18+
"test:integration:watch": "yarn g:vitest run --passWithNoTests -c vitest.config.integ.mts",
19+
"test:watch": "yarn g:vitest watch --passWithNoTests"
1620
},
1721
"main": "./dist-cjs/index.js",
1822
"types": "./dist-types/index.d.ts",
@@ -61,12 +65,14 @@
6165
"tslib": "^2.6.2"
6266
},
6367
"devDependencies": {
68+
"@smithy/snapshot-testing": "^1.0.7",
6469
"@tsconfig/node20": "20.1.8",
6570
"@types/node": "^20.14.8",
6671
"concurrently": "7.0.0",
6772
"downlevel-dts": "0.10.1",
6873
"premove": "4.0.0",
69-
"typescript": "~5.8.3"
74+
"typescript": "~5.8.3",
75+
"vitest": "^4.0.17"
7076
},
7177
"engines": {
7278
"node": ">=20.0.0"
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// smithy-typescript generated code
2+
import { SnapshotRunner } from "@smithy/snapshot-testing";
3+
import { join } from "node:path";
4+
import { describe, expect, test as it, vi } from "vitest";
5+
6+
import {
7+
AppConfigDataClient,
8+
GetLatestConfiguration$,
9+
GetLatestConfigurationCommand,
10+
StartConfigurationSession$,
11+
StartConfigurationSessionCommand,
12+
} from "../src";
13+
14+
vi.setSystemTime(new Date(946702799999));
15+
const Client = AppConfigDataClient;
16+
17+
const mode = (process.env.SNAPSHOT_MODE as "write" | "compare") ?? "write";
18+
19+
describe(
20+
"AppConfigDataClient" + ` (${mode})`,
21+
() => {
22+
const runner = new SnapshotRunner({
23+
snapshotDirPath: join(__dirname, "snapshots"),
24+
Client,
25+
mode,
26+
testCase(caseName: string, run: () => Promise<void>) {
27+
it(caseName, run);
28+
},
29+
assertions(caseName: string, expected: string, actual: string): Promise<void> {
30+
expect(actual).toEqual(expected);
31+
return Promise.resolve();
32+
},
33+
schemas: new Map<any, any>([
34+
[GetLatestConfiguration$, GetLatestConfigurationCommand],
35+
[StartConfigurationSession$, StartConfigurationSessionCommand],
36+
]),
37+
});
38+
39+
runner.run();
40+
},
41+
30_000
42+
);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
GET https://appconfigdata.us-east-1.amazonaws.com
2+
/configuration?configuration_token=__ConfigurationToken__
3+
4+
x-amz-user-agent: aws-sdk-js/3.___._
5+
user-agent: aws-sdk-js/3.___._ ua/2.1 lang/js md/nodejs#_.__ api/appconfigdata#_.__ m/E,e
6+
host: appconfigdata.us-east-1.amazonaws.com
7+
amz-sdk-invocation-id: 1111abcd-uuid-uuid-uuid-000000001111
8+
amz-sdk-request: attempt=1; max=3
9+
x-amz-date: 19991231T235959Z
10+
x-amz-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
11+
authorization: AWS4-HMAC-SHA256 Credential=***/19991231/us-east-1/appconfig/aws4_request, SignedHeaders=amz-sdk-invocation-id;amz-sdk-request;host;x-amz-content-sha256;x-amz-date;x-amz-user-agent, Signature=***
12+
13+
[no body]
14+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
POST https://appconfigdata.us-east-1.amazonaws.com
2+
/configurationsessions
3+
4+
content-type: application/json
5+
content-length: 216
6+
x-amz-user-agent: aws-sdk-js/3.___._
7+
user-agent: aws-sdk-js/3.___._ ua/2.1 lang/js md/nodejs#_.__ api/appconfigdata#_.__ m/E,e
8+
host: appconfigdata.us-east-1.amazonaws.com
9+
amz-sdk-invocation-id: 1111abcd-uuid-uuid-uuid-000000001111
10+
amz-sdk-request: attempt=1; max=3
11+
x-amz-date: 19991231T235959Z
12+
x-amz-content-sha256: 69cbe1ca2e7167c598a03db44f0ef0615d5fa57f7235bb15b8f1392a850b72d7
13+
authorization: AWS4-HMAC-SHA256 Credential=***/19991231/us-east-1/appconfig/aws4_request, SignedHeaders=amz-sdk-invocation-id;amz-sdk-request;content-length;content-type;host;x-amz-content-sha256;x-amz-date;x-amz-user-agent, Signature=***
14+
15+
[string (json)]
16+
{
17+
"ApplicationIdentifier": "__ApplicationIdentifier__",
18+
"EnvironmentIdentifier": "__EnvironmentIdentifier__",
19+
"ConfigurationProfileIdentifier": "__ConfigurationProfileIdentifier__",
20+
"RequiredMinimumPollIntervalInSeconds": 0
21+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { defineConfig } from "vitest/config";
2+
3+
export default defineConfig({
4+
test: {
5+
include: ["**/*.integ.spec.ts"],
6+
environment: "node",
7+
},
8+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { defineConfig } from "vitest/config";
2+
3+
export default defineConfig({
4+
test: {
5+
exclude: ["**/*.{integ}.spec.ts"],
6+
include: ["**/*.spec.ts"],
7+
globals: true,
8+
},
9+
});

clients/client-bedrock-runtime/package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
"clean": "premove dist-cjs dist-es dist-types tsconfig.cjs.tsbuildinfo tsconfig.es.tsbuildinfo tsconfig.types.tsbuildinfo",
1313
"extract:docs": "api-extractor run --local",
1414
"generate:client": "node ../../scripts/generate-clients/single-service --solo bedrock-runtime",
15-
"test:index": "tsc --noEmit ./test/index-types.ts && node ./test/index-objects.spec.mjs"
15+
"test": "yarn g:vitest run --passWithNoTests",
16+
"test:index": "tsc --noEmit ./test/index-types.ts && node ./test/index-objects.spec.mjs",
17+
"test:integration": "yarn g:vitest run --passWithNoTests -c vitest.config.integ.mts",
18+
"test:integration:watch": "yarn g:vitest run --passWithNoTests -c vitest.config.integ.mts",
19+
"test:watch": "yarn g:vitest watch --passWithNoTests"
1620
},
1721
"main": "./dist-cjs/index.js",
1822
"types": "./dist-types/index.d.ts",
@@ -68,12 +72,14 @@
6872
"tslib": "^2.6.2"
6973
},
7074
"devDependencies": {
75+
"@smithy/snapshot-testing": "^1.0.7",
7176
"@tsconfig/node20": "20.1.8",
7277
"@types/node": "^20.14.8",
7378
"concurrently": "7.0.0",
7479
"downlevel-dts": "0.10.1",
7580
"premove": "4.0.0",
76-
"typescript": "~5.8.3"
81+
"typescript": "~5.8.3",
82+
"vitest": "^4.0.17"
7783
},
7884
"engines": {
7985
"node": ">=20.0.0"
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// smithy-typescript generated code
2+
import { SnapshotRunner } from "@smithy/snapshot-testing";
3+
import { join } from "node:path";
4+
import { describe, expect, test as it, vi } from "vitest";
5+
6+
import {
7+
ApplyGuardrail$,
8+
ApplyGuardrailCommand,
9+
BedrockRuntimeClient,
10+
Converse$,
11+
ConverseCommand,
12+
ConverseStream$,
13+
ConverseStreamCommand,
14+
CountTokens$,
15+
CountTokensCommand,
16+
GetAsyncInvoke$,
17+
GetAsyncInvokeCommand,
18+
InvokeModel$,
19+
InvokeModelCommand,
20+
InvokeModelWithBidirectionalStream$,
21+
InvokeModelWithBidirectionalStreamCommand,
22+
InvokeModelWithResponseStream$,
23+
InvokeModelWithResponseStreamCommand,
24+
ListAsyncInvokes$,
25+
ListAsyncInvokesCommand,
26+
StartAsyncInvoke$,
27+
StartAsyncInvokeCommand,
28+
} from "../src";
29+
30+
vi.setSystemTime(new Date(946702799999));
31+
const Client = BedrockRuntimeClient;
32+
33+
const mode = (process.env.SNAPSHOT_MODE as "write" | "compare") ?? "write";
34+
35+
describe(
36+
"BedrockRuntimeClient" + ` (${mode})`,
37+
() => {
38+
const runner = new SnapshotRunner({
39+
snapshotDirPath: join(__dirname, "snapshots"),
40+
Client,
41+
mode,
42+
testCase(caseName: string, run: () => Promise<void>) {
43+
it(caseName, run);
44+
},
45+
assertions(caseName: string, expected: string, actual: string): Promise<void> {
46+
expect(actual).toEqual(expected);
47+
return Promise.resolve();
48+
},
49+
schemas: new Map<any, any>([
50+
[ApplyGuardrail$, ApplyGuardrailCommand],
51+
[Converse$, ConverseCommand],
52+
[ConverseStream$, ConverseStreamCommand],
53+
[CountTokens$, CountTokensCommand],
54+
[GetAsyncInvoke$, GetAsyncInvokeCommand],
55+
[InvokeModel$, InvokeModelCommand],
56+
[InvokeModelWithBidirectionalStream$, InvokeModelWithBidirectionalStreamCommand],
57+
[InvokeModelWithResponseStream$, InvokeModelWithResponseStreamCommand],
58+
[ListAsyncInvokes$, ListAsyncInvokesCommand],
59+
[StartAsyncInvoke$, StartAsyncInvokeCommand],
60+
]),
61+
});
62+
63+
runner.run();
64+
},
65+
30_000
66+
);
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
POST https://bedrock-runtime.us-east-1.amazonaws.com
2+
/guardrail/__guardrailIdentifier__/version/__guardrailVersion__/apply
3+
4+
content-type: application/json
5+
content-length: 297
6+
x-amz-user-agent: aws-sdk-js/3.___._
7+
user-agent: aws-sdk-js/3.___._ ua/2.1 lang/js md/nodejs#_.__ api/bedrock-runtime#_.__ m/E,e
8+
host: bedrock-runtime.us-east-1.amazonaws.com
9+
amz-sdk-invocation-id: 1111abcd-uuid-uuid-uuid-000000001111
10+
amz-sdk-request: attempt=1; max=3
11+
x-amz-date: 19991231T235959Z
12+
x-amz-content-sha256: 9c7975b8031b79ec9d5eb191697d8c7eeedac2e46613cd0822bf0de0472cbe6b
13+
authorization: AWS4-HMAC-SHA256 Credential=***/19991231/us-east-1/bedrock/aws4_request, SignedHeaders=amz-sdk-invocation-id;amz-sdk-request;content-length;content-type;host;x-amz-content-sha256;x-amz-date;x-amz-user-agent, Signature=***
14+
15+
[string (json)]
16+
{
17+
"source": "__source__",
18+
"content": [
19+
{
20+
"text": {
21+
"text": "__text__",
22+
"qualifiers": [
23+
"__member__",
24+
"__member__",
25+
"__member__"
26+
]
27+
}
28+
},
29+
{
30+
"image": {
31+
"format": "__format__",
32+
"source": {
33+
"bytes": "AQAAAQ=="
34+
}
35+
}
36+
},
37+
{
38+
"text": {
39+
"text": "__text__",
40+
"qualifiers": [
41+
"__member__",
42+
"__member__",
43+
"__member__"
44+
]
45+
}
46+
}
47+
],
48+
"outputScope": "__outputScope__"
49+
}

0 commit comments

Comments
 (0)