Skip to content

Commit d7bf51a

Browse files
committed
chore: install vitest
1 parent 053a868 commit d7bf51a

21 files changed

+489
-26
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
"turbo": "2.1.2",
122122
"typescript": "~4.9.5",
123123
"verdaccio": "5.25.0",
124+
"vitest": "0.34.6",
124125
"webpack": "5.76.0",
125126
"webpack-cli": "4.10.0",
126127
"yargs": "17.5.1",

packages/core/integ/request-handlers/request-handlers.integ.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { XhrHttpHandler } from "@aws-sdk/xhr-http-handler";
66
import { FetchHttpHandler } from "@smithy/fetch-http-handler";
77
import { NodeHttp2Handler, NodeHttpHandler } from "@smithy/node-http-handler";
88
import { Agent } from "https";
9+
import { describe, expect, test as it } from "vitest";
910

1011
describe("request handler initialization", () => {
1112
describe("http", () => {

packages/core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"lint": "node ./scripts/lint.js",
1313
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo",
1414
"extract:docs": "api-extractor run --local",
15-
"test": "jest",
16-
"test:integration": "jest -c jest.config.integ.js"
15+
"test": "vitest run",
16+
"test:integration": "vitest run -c vitest.config.integ.ts"
1717
},
1818
"main": "./dist-cjs/index.js",
1919
"module": "./dist-es/index.js",

packages/core/src/submodules/account-id-endpoint/AccountIdEndpointModeConstants.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { describe, expect, test as it } from "vitest";
2+
13
import { validateAccountIdEndpointMode } from "./AccountIdEndpointModeConstants";
24

35
describe("validateAccountIdEndpointMode", () => {

packages/core/src/submodules/account-id-endpoint/NodeAccountIdEndpointModeConfigOptions.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { afterEach, beforeEach, describe, expect, test as it, vi } from "vitest";
2+
13
import { DEFAULT_ACCOUNT_ID_ENDPOINT_MODE } from "./AccountIdEndpointModeConstants";
24
import {
35
CONFIG_ACCOUNT_ID_ENDPOINT_MODE,
@@ -9,7 +11,7 @@ describe("NODE_ACCOUNT_ID_ENDPOINT_MODE_CONFIG_OPTIONS", () => {
911
const originalEnv = process.env;
1012

1113
beforeEach(() => {
12-
jest.resetModules();
14+
vi.resetModules();
1315
process.env = { ...originalEnv };
1416
});
1517

packages/core/src/submodules/client/emitWarningIfUnsupportedVersion.spec.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1+
import { afterEach, describe, expect, test as it, vi } from "vitest";
2+
3+
import { emitWarningIfUnsupportedVersion, state } from "./emitWarningIfUnsupportedVersion";
4+
15
describe("emitWarningIfUnsupportedVersion", () => {
2-
let emitWarningIfUnsupportedVersion: any;
36
const emitWarning = process.emitWarning;
47
const supportedVersion = "18.0.0";
58

6-
beforeEach(() => {
7-
const module = require("./emitWarningIfUnsupportedVersion");
8-
emitWarningIfUnsupportedVersion = module.emitWarningIfUnsupportedVersion;
9-
});
9+
vi.spyOn(process, "emitWarning");
1010

1111
afterEach(() => {
12-
jest.clearAllMocks();
13-
jest.resetModules();
12+
state.warningEmitted = false;
13+
vi.clearAllMocks();
14+
vi.resetModules();
1415
process.emitWarning = emitWarning;
1516
});
1617

@@ -31,7 +32,7 @@ describe("emitWarningIfUnsupportedVersion", () => {
3132
[getPreviousMajorVersion(major), 0, 0],
3233
].map((arr) => `v${arr.join(".")}`)
3334
)(`%s`, async (unsupportedVersion) => {
34-
process.emitWarning = jest.fn();
35+
process.emitWarning = vi.fn() as any;
3536
emitWarningIfUnsupportedVersion(unsupportedVersion);
3637

3738
// Verify that the warning was emitted.
@@ -62,7 +63,7 @@ More information can be found at: https://a.co/74kJMmI`
6263
[major + 1, 0, 0],
6364
].map((arr) => `v${arr.join(".")}`)
6465
)(`%s`, async (unsupportedVersion) => {
65-
process.emitWarning = jest.fn();
66+
process.emitWarning = vi.fn() as any;
6667
emitWarningIfUnsupportedVersion(unsupportedVersion);
6768
expect(process.emitWarning).not.toHaveBeenCalled();
6869
});

packages/core/src/submodules/client/emitWarningIfUnsupportedVersion.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
// Stores whether the warning was already emitted.
2-
let warningEmitted = false;
1+
/**
2+
* @internal
3+
* Stores whether the warning was already emitted.
4+
*/
5+
export const state = {
6+
warningEmitted: false,
7+
};
38

49
/**
510
* @internal
@@ -10,8 +15,8 @@ let warningEmitted = false;
1015
* @param version - The Node.js version string.
1116
*/
1217
export const emitWarningIfUnsupportedVersion = (version: string) => {
13-
if (version && !warningEmitted && parseInt(version.substring(1, version.indexOf("."))) < 18) {
14-
warningEmitted = true;
18+
if (version && !state.warningEmitted && parseInt(version.substring(1, version.indexOf("."))) < 18) {
19+
state.warningEmitted = true;
1520
process.emitWarning(
1621
`NodeDeprecationWarning: The AWS SDK for JavaScript (v3) will
1722
no longer support Node.js 16.x on January 6, 2025.

packages/core/src/submodules/client/setCredentialFeature.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { AttributedAwsCredentialIdentity } from "@aws-sdk/types";
2+
import { describe, expect, test as it } from "vitest";
23

34
import { setCredentialFeature } from "./setCredentialFeature";
45

packages/core/src/submodules/client/setFeature.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { AwsHandlerExecutionContext } from "@aws-sdk/types";
2+
import { describe, expect, test as it } from "vitest";
23

34
import { setFeature } from "./setFeature";
45

packages/core/src/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { describe, expect, test as it } from "vitest";
2+
13
import { AwsSdkSigV4Signer } from "./AwsSdkSigV4Signer";
24

35
describe(AwsSdkSigV4Signer.name, () => {

0 commit comments

Comments
 (0)