Skip to content

Commit fc3af97

Browse files
authored
Run Typescript Test CI on all supported Node versions (#1261)
Fix tests for the following packages: - @smithy/abort-controller: remove unused `useFakeTimers()` call - @smithy/util-stream-browser: update test global writable for Blob and ReadableStream - @aws-smithy/server-node: loosen test matcher for connection header
1 parent 3500f34 commit fc3af97

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

.changeset/fuzzy-lions-flow.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

.github/workflows/ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,16 @@ jobs:
4444

4545
test-typescript:
4646
runs-on: smithy-typescript_ubuntu-latest_8-core
47-
name: TypeScript Test
47+
name: TypeScript Test ${{ matrix.node }}
48+
strategy:
49+
matrix:
50+
node: [16, 18, 20, 22]
51+
4852
steps:
4953
- uses: actions/checkout@v4
5054
- uses: actions/setup-node@v4
5155
with:
52-
node-version: 16
56+
node-version: ${{ matrix.node }}
5357
cache: "yarn"
5458
- uses: gradle/wrapper-validation-action@v2
5559
- name: Set up JDK 17

packages/abort-controller/src/AbortController.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { AbortController } from "./AbortController";
22
import { AbortSignal } from "./AbortSignal";
33

4-
jest.useFakeTimers();
5-
64
describe("AbortController", () => {
75
it("should communicate cancellation via its signal", () => {
86
const source = new AbortController();

packages/util-stream-browser/src/sdk-stream-mixin.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ jest.mock("@smithy/util-utf8");
1414

1515
const mockStreamCollectorReturn = Uint8Array.from([117, 112, 113]);
1616
(streamCollector as jest.Mock).mockReturnValue(mockStreamCollectorReturn);
17+
Object.defineProperty(global, "Blob", {
18+
writable: true,
19+
});
20+
Object.defineProperty(global, "ReadableStream", {
21+
writable: true,
22+
});
1723

1824
describe(sdkStreamMixin.name, () => {
1925
const expectAllTransformsToFail = async (sdkStream: SdkStreamMixin) => {

smithy-typescript-ssdk-libs/server-node/src/index.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ describe("convertRequest", () => {
6969
expect(convertedReq.path).toEqual("/");
7070
expect(convertedReq.protocol).toEqual("http:");
7171
expect(convertedReq.query).toEqual({});
72-
expect(convertedReq.headers).toEqual({
73-
connection: "close",
72+
expect(convertedReq.headers).toMatchObject({
7473
host: "example.com",
74+
// From LTS 18 -> 20, the connection header defaults from "close" to "keep-alive", so don't test explicitly
7575
});
7676
expect(await streamToString(convertedReq.body)).toEqual("");
7777
});
@@ -92,10 +92,10 @@ describe("convertRequest", () => {
9292
q: "hello",
9393
a: "world",
9494
});
95-
expect(convertedReq.headers).toEqual({
96-
connection: "close",
95+
expect(convertedReq.headers).toMatchObject({
9796
host: "example.com",
9897
"content-length": "5",
98+
// From LTS 18 -> 20, the connection header defaults from "close" to "keep-alive", so don't test explicitly
9999
});
100100
expect(await streamToString(convertedReq.body)).toEqual("hello");
101101
});
@@ -116,12 +116,12 @@ describe("convertRequest", () => {
116116
expect(convertedReq.path).toEqual("/some/resource");
117117
expect(convertedReq.protocol).toEqual("http:");
118118
expect(convertedReq.query).toEqual({});
119-
expect(convertedReq.headers).toEqual({
119+
expect(convertedReq.headers).toMatchObject({
120120
"access-control-request-headers": "origin, x-requested-with",
121121
"access-control-request-method": "DELETE",
122122
origin: "https://example.com",
123-
connection: "close",
124123
host: "example.com",
124+
// From LTS 18 -> 20, the connection header defaults from "close" to "keep-alive", so don't test explicitly
125125
});
126126
expect(await streamToString(convertedReq.body)).toEqual("");
127127
});

0 commit comments

Comments
 (0)