Skip to content

Commit 9eee6eb

Browse files
authored
test(credential-provider-node): rewrite integ in vitest (#7349)
* test(credential-provider-node): rewrite integ in vitest * test(credential-provider-sso): convert integ to vitest
1 parent 60f5a8c commit 9eee6eb

File tree

18 files changed

+311
-301
lines changed

18 files changed

+311
-301
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ test-schema: bundles
3535
test-integration: bundles
3636
rm -rf ./clients/client-sso/node_modules/\@smithy # todo(yarn) incompatible redundant nesting.
3737
yarn g:vitest run -c vitest.config.integ.mts
38-
npx jest -c jest.config.integ.js
3938
make test-protocols
4039
make test-types
4140
make test-endpoints

jest.config.e2e.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

jest.config.integ.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

packages/credential-provider-http/src/fromHttp/fromHttp.spec.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@ const credentials = {
1414

1515
const mockToken = "abcd";
1616

17-
const mockResponse = {
18-
AccessKeyId: credentials.accessKeyId,
19-
SecretAccessKey: credentials.secretAccessKey,
20-
Token: credentials.sessionToken,
21-
AccountId: "123",
22-
Expiration: new Date(credentials.expiration).toISOString(), // rfc3339
23-
};
24-
2517
const mockHandle = vi.fn().mockResolvedValue({
2618
response: new HttpResponse({
2719
statusCode: 200,
@@ -33,10 +25,16 @@ const mockHandle = vi.fn().mockResolvedValue({
3325
});
3426

3527
vi.mock("@smithy/node-http-handler", () => ({
36-
NodeHttpHandler: vi.fn().mockImplementation(() => ({
37-
destroy: () => {},
38-
handle: mockHandle,
39-
})),
28+
NodeHttpHandler: (() => {
29+
const getImpl = () => ({
30+
destroy: () => {},
31+
handle: mockHandle,
32+
});
33+
const impl = Object.assign(vi.fn().mockImplementation(getImpl), {
34+
create: () => getImpl(),
35+
});
36+
return impl;
37+
})(),
4038
streamCollector: vi.fn(),
4139
}));
4240

packages/credential-provider-http/src/fromHttp/fromHttp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
6666
// throws if not to spec for provider.
6767
checkUrl(url, options.logger);
6868

69-
const requestHandler = new NodeHttpHandler({
69+
const requestHandler = NodeHttpHandler.create({
7070
requestTimeout: options.timeout ?? 1000,
7171
connectionTimeout: options.timeout ?? 1000,
7272
});

packages/credential-provider-node/jest.config.integ.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

packages/credential-provider-node/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
"build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
1717
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo",
1818
"test": "yarn g:vitest run",
19-
"test:integration": "yarn g:jest -c jest.config.integ.js",
20-
"test:watch": "yarn g:vitest watch"
19+
"test:watch": "yarn g:vitest watch",
20+
"test:integration": "yarn g:vitest run -c vitest.config.integ.mts",
21+
"test:integration:watch": "yarn g:vitest watch -c vitest.config.integ.mts"
2122
},
2223
"keywords": [
2324
"aws",

0 commit comments

Comments
 (0)