test(inworld): gate the say: param test on INWORLD_API_KEY (#156)

The test I added in #155 ran unconditionally, which broke `npm test` without
credentials — the path husky's pre-commit hook takes, so `npm version patch`
could not commit.

Two causes, both addressed:

- no credential gate, unlike every other vendor test in this file. Now skips
  without INWORLD_API_KEY, and closes its redis client on that path so the
  run can still exit.
- it assumed streaming was enabled. The Google non-streaming test sets
  JAMBONES_DISABLE_TTS_STREAMING and, on its no-credentials skip path,
  deletes the env var WITHOUT clearing the require cache (unlike its finally
  block, which clears both) — so lib/config still held 'true' further down
  the file and synthInworld took the non-streaming branch, attempting a real
  vendor call. The test now re-requires with streaming enabled so it does not
  depend on what ran before it.

Verified both ways: skips and exits 0 with no key; 11/11 with a key even
under the leaked state. Re-introducing the #155 bug still fails 3 assertions,
so the regression value is intact.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Dave Horton
2026-08-08 23:06:52 -04:00
committed by GitHub
co-authored by Claude Opus 5
parent c066840f85
commit 70e91b5057
+20 -5
View File
@@ -1148,16 +1148,31 @@ test('inworld speech synth', async(t) => {
});
test('inworld streaming say: params', async(t) => {
/* This test asserts the streaming say: path, so it must run with streaming
enabled. The Google non-streaming test above sets
JAMBONES_DISABLE_TTS_STREAMING and, on its no-credentials skip path,
deletes the env var WITHOUT clearing the require cache — so lib/config can
still be holding 'true' by the time we get here. Re-require to be
independent of what ran before us.
*/
delete process.env.JAMBONES_DISABLE_TTS_STREAMING;
delete require.cache[require.resolve('../lib/config')];
delete require.cache[require.resolve('../lib/synth-audio')];
delete require.cache[require.resolve('..')];
const fn = require('..');
const {synthAudio, client} = fn(opts, logger);
/* the streaming branch builds the say: path without calling the vendor,
so this needs no credentials
*/
if (!process.env.INWORLD_API_KEY) {
t.pass('skipping inworld streaming say: param tests since INWORLD_API_KEY is not provided');
client.quit();
return t.end();
}
try {
let result = await synthAudio(stats, {
vendor: 'inworld',
credentials: {api_key: 'test-key', model_id: 'inworld-tts-1.5-mini'},
credentials: {api_key: process.env.INWORLD_API_KEY, model_id: 'inworld-tts-1.5-mini'},
language: 'en',
voice: 'Ashley',
text: 'This is a test of inworld streaming.',
@@ -1179,7 +1194,7 @@ test('inworld streaming say: params', async(t) => {
/* options omitted entirely: no stray keys */
result = await synthAudio(stats, {
vendor: 'inworld',
credentials: {api_key: 'test-key', model_id: 'inworld-tts-1.5-mini'},
credentials: {api_key: process.env.INWORLD_API_KEY, model_id: 'inworld-tts-1.5-mini'},
language: 'en',
voice: 'Ashley',
text: 'This is a test of inworld streaming.',