Skip to content

Commit d930c21

Browse files
authored
test(core): install vitest (#6581)
* chore: install vitest * test: set vite to 4.x
1 parent 6810a1a commit d930c21

25 files changed

+310
-44
lines changed

.github/workflows/pre-commit-hooks.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v4
14-
14+
1515
- name: set up Node.js
1616
uses: actions/setup-node@v3
1717
with:
18-
node-version: '16'
18+
node-version: '18'
1919
cache: 'yarn'
20-
20+
2121
- name: install dependencies
2222
run: yarn install --frozen-lockfile
23-
23+
2424
- name: run pre-commit hooks
2525
run: |
2626
yarn lint-staged

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,19 @@
121121
"turbo": "2.1.2",
122122
"typescript": "~4.9.5",
123123
"verdaccio": "5.25.0",
124+
"vite": "4.5.5",
125+
"vitest": "0.34.6",
124126
"webpack": "5.76.0",
125127
"webpack-cli": "4.10.0",
126128
"yargs": "17.5.1",
127129
"yarn": "1.22.13"
128130
},
131+
"overrides": {
132+
"vite": "4.5.5"
133+
},
134+
"resolutions": {
135+
"vite": "4.5.5"
136+
},
129137
"workspaces": {
130138
"packages": [
131139
"clients/*",

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { test as it, describe, expect } from "vitest";
2+
13
import { Kinesis } from "@aws-sdk/client-kinesis";
24
import { S3 } from "@aws-sdk/client-s3";
35
import { TranscribeStreaming } from "@aws-sdk/client-transcribe-streaming";

packages/core/jest.config.integ.js

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

packages/core/jest.config.js

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

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,17 +1,18 @@
1+
import { afterEach, beforeEach, 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+
beforeEach(() => {});
1010

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

1718
describe(`emits warning for Node.js <${supportedVersion}`, () => {
@@ -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: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Stores whether the warning was already emitted.
2-
let warningEmitted = false;
2+
export const state = {
3+
warningEmitted: false,
4+
};
35

46
/**
57
* @internal
@@ -10,8 +12,8 @@ let warningEmitted = false;
1012
* @param version - The Node.js version string.
1113
*/
1214
export const emitWarningIfUnsupportedVersion = (version: string) => {
13-
if (version && !warningEmitted && parseInt(version.substring(1, version.indexOf("."))) < 18) {
14-
warningEmitted = true;
15+
if (version && !state.warningEmitted && parseInt(version.substring(1, version.indexOf("."))) < 18) {
16+
state.warningEmitted = true;
1517
process.emitWarning(
1618
`NodeDeprecationWarning: The AWS SDK for JavaScript (v3) will
1719
no longer support Node.js 16.x on January 6, 2025.

0 commit comments

Comments
 (0)