test(js): fix async assertions and force exit on test completion#5613
test(js): fix async assertions and force exit on test completion#5613pavelgj wants to merge 1 commit into
Conversation
Add missing `await` to `assert.rejects` calls in google-cloud metrics tests to ensure rejections are properly verified. Add `--test-force-exit` flag to ai and vercel-ai test scripts to prevent hanging processes after tests complete.
There was a problem hiding this comment.
Code Review
This pull request adds the --test-force-exit flag to test scripts in js/ai/package.json and js/plugins/vercel-ai/package.json, and fixes several unawaited assert.rejects calls in js/plugins/google-cloud/tests/metrics_test.ts. The reviewer noted that the --test-force-exit flag was introduced in Node.js v22.10.0 and will cause test failures on older supported Node.js versions (such as Node.js 20). It is recommended to resolve the underlying resource leaks instead of forcing the process to exit.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| "build": "npm-run-all build:clean check compile", | ||
| "build:watch": "tsup-node --watch", | ||
| "test": "node --import tsx --test ./tests/**/*_test.ts ./tests/*_test.ts", | ||
| "test": "node --import tsx --test --test-force-exit ./tests/**/*_test.ts ./tests/*_test.ts", |
There was a problem hiding this comment.
The --test-force-exit flag was introduced in Node.js v22.10.0. Since this repository supports Node.js >=20, running tests on Node.js 20 or older Node.js 22 versions will fail with a bad option: --test-force-exit error. It is highly recommended to resolve the underlying resource leaks (such as unclosed servers, active timers, or open handles) instead of forcing the process to exit, to ensure compatibility across all supported Node.js versions.
| "build": "npm-run-all build:clean check compile", | ||
| "build:watch": "tsup-node --watch", | ||
| "test": "tsx --test ./tests/*_test.ts" | ||
| "test": "tsx --test --test-force-exit ./tests/*_test.ts" |
There was a problem hiding this comment.
The --test-force-exit flag was introduced in Node.js v22.10.0. Since this package specifies "engines": { "node": ">=20" }, running tests on Node.js 20 or older Node.js 22 versions will fail with a bad option: --test-force-exit error. Consider identifying and cleaning up the active handles (such as unclosed servers or active timers) causing the tests to hang, rather than using this flag.
Add missing
awaittoassert.rejectscalls in google-cloud metrics tests to ensure rejections are properly verified. Add--test-force-exitflag to ai and vercel-ai test scripts to prevent hanging processes after tests complete.