Skip to content

Commit 3c128cd

Browse files
committed
test(client-transcribe-streaming): add integration test
1 parent 77e5db2 commit 3c128cd

File tree

8 files changed

+60
-2
lines changed

8 files changed

+60
-2
lines changed

clients/client-transcribe-streaming/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ package-lock.json
1111

1212
*.d.ts
1313
*.js
14+
!jest*.config.js
1415
*.js.map
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/coverage/
22
/docs/
3+
/test/
34
tsconfig.test.json
45
*.tsbuildinfo
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const base = require("../../jest.config.base.js");
2+
3+
module.exports = {
4+
...base,
5+
// Only test cjs dist, avoid testing the package twice
6+
testPathIgnorePatterns: ["/node_modules/", "/es/", ".*.integ.spec.js"],
7+
coveragePathIgnorePatterns: [
8+
"/node_modules/",
9+
"/commands/",
10+
"/protocols/", // protocols tested in protocol protocol_tests folder
11+
"endpoints" // endpoint tested in tests/functional/endpoints
12+
]
13+
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const base = require("../../jest.config.base.js");
2+
3+
module.exports = {
4+
...base,
5+
testMatch: ["**/*.integ.spec.js"]
6+
};

clients/client-transcribe-streaming/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"remove-documentation": "rimraf ./docs",
1313
"remove-js": "rimraf *.js && rimraf ./commands/*.js && rimraf ./models/*.js && rimraf ./protocols/*.js",
1414
"remove-maps": "rimraf *.js.map && rimraf ./commands/*.js.map && rimraf ./models/*.js.map && rimraf ./protocols/*.js.map",
15-
"test": "exit 0",
15+
"test": "yarn build && jest --coverage --passWithNoTests",
1616
"build:es": "tsc -p tsconfig.es.json",
1717
"build": "yarn pretest && yarn build:es"
1818
},
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { TranscribeStreaming } from "../index";
2+
import { createReadStream } from "fs";
3+
import { join } from "path";
4+
const moduleRoot = join(__dirname, "..", "..", "..");
5+
const audio = createReadStream(join(moduleRoot, "test", "speech.wav"));
6+
7+
describe("TranscribeStream client", () => {
8+
const client = new TranscribeStreaming({});
9+
afterAll(() => {
10+
client.destroy();
11+
});
12+
13+
it("should stream the transcript", async () => {
14+
const result = await client.startStreamTranscription({
15+
LanguageCode: "en-US",
16+
MediaEncoding: "pcm",
17+
MediaSampleRateHertz: 44100,
18+
AudioStream: (async function* () {
19+
for await (const chunk of audio) {
20+
yield { AudioEvent: { AudioChunk: chunk } };
21+
}
22+
})()
23+
});
24+
expect(result.LanguageCode).toBe("en-US");
25+
expect(result.MediaEncoding).toBe("pcm");
26+
expect(result.MediaSampleRateHertz).toBe(44100);
27+
expect(result.TranscriptResultStream).toBeDefined();
28+
const transcripts = [];
29+
for await (const event of result.TranscriptResultStream!) {
30+
transcripts.push(event);
31+
}
32+
expect(
33+
transcripts.filter(event => event["TranscriptEvent"]).length
34+
).toBeGreaterThan(0);
35+
}, 60000);
36+
});
Binary file not shown.

clients/client-transcribe-streaming/tsconfig.es.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
"es2015.symbol.wellknown"
1616
],
1717
"outDir": "dist/es"
18-
}
18+
},
19+
"exclude": ["test"]
1920
}

0 commit comments

Comments
 (0)