hyperdx/packages/common-utils/package.json
Brandon Pereira 7335a23acd
chore: improve integration test infrastructure (#2126)
## Summary

Currently it's hard to debug integration tests because of all the extra logging/warnings/open handler issues (wasn't sure if I introduced an open handler or was existing). This fixes that.

- Bump Jest from v28 to v30 in api and common-utils packages, syncing with app's existing setup
- Replace legacy `preset: 'ts-jest'` with modern `createJsWithTsPreset()` spread pattern across all packages
- Fix open handles that required `--forceExit` and `--detectOpenHandles` workarounds
- Suppress noisy console and logger output during test runs via targeted mocks

## Changes

### Jest/ts-jest upgrade
- Bump `jest` 28 → 30, `@types/jest` 28 → 29 in api and common-utils
- Adopt `createJsWithTsPreset()` config pattern (matching app)
- Add `isolatedModules: true` to common-utils tsconfig to fix ts-jest warning with Node16 module kind
- Update snapshot files and inline snapshots for Jest 30 format changes
- Replace removed `toThrowError()` with `toThrow()`
- Fix team.test.ts inline snapshot that depended on dynamic Mongo ObjectIds

### Open handle fixes
- Add `close()` method to `BaseClickhouseClient` in common-utils
- Call `mongoose.disconnect()` in `closeDB()` (api fixtures)
- Add `closeTestFixtureClickHouseClient()` and call it in `MockServer.stop()`
- Fix common-utils integration tests to close both `hdxClient` and raw `client` in `afterAll`
- Disable `usageStats()` interval in CI to prevent leaked timers
- Remove `--forceExit` from common-utils CI/dev scripts and api dev script
- Remove `--detectOpenHandles` from all dev scripts

### Log noise suppression
- Use `jest.spyOn` for console methods instead of global console object override
- Add per-file `console.warn`/`console.error` suppression in test files that exercise error paths
- Mock pino logger module in api jest.setup.ts to suppress expected operational logs (validation errors, MCP tool errors, etc.)
- Use pino logger instead of `console.error` in Express error handler (`middleware/error.ts`)
- Add console suppression to app setupTests.tsx

## Testing
- `make ci-lint` — passes
- `make ci-unit` — 2177 tests pass, zero console noise
- `make ci-int` — 642 tests pass (606 api + 36 common-utils), zero log noise
2026-04-16 00:12:13 +00:00

53 lines
1.6 KiB
JSON

{
"name": "@hyperdx/common-utils",
"description": "Common utilities for HyperDX application",
"version": "0.17.1",
"license": "MIT",
"private": true,
"files": [
"dist/*"
],
"engines": {
"node": ">=22.16.0"
},
"dependencies": {
"@clickhouse/client": "^1.12.1",
"@clickhouse/client-common": "^1.12.1",
"@clickhouse/client-web": "^1.12.1",
"@hyperdx/lucene": "^3.1.1",
"date-fns": "^2.28.0",
"date-fns-tz": "^2.0.0",
"lodash": "^4.17.23",
"node-sql-parser": "^5.3.5",
"object-hash": "^3.0.0",
"sql-formatter": "^15.7.2",
"sqlstring": "^2.3.3",
"zod": "3.25"
},
"devDependencies": {
"@types/hyperdx__lucene": "npm:@types/lucene@*",
"@types/jest": "^29.5.14",
"@types/lodash": "^4.14.198",
"@types/object-hash": "^2.2.1",
"@types/sqlstring": "^2.3.0",
"dotenv": "^17.2.3",
"jest": "^30.2.0",
"nodemon": "^2.0.20",
"ts-jest": "^29.4.5",
"tsup": "^8.4.0",
"typescript": "^5.9.3"
},
"scripts": {
"dev": "nodemon --on-change-only --watch ./src --ext ts --exec \"yarn dev:build\"",
"dev:build": "tsup && tsc --emitDeclarationOnly --declaration",
"build": "tsup",
"ci:build": "tsup",
"lint": "npx eslint --quiet . --ext .ts",
"lint:fix": "npx eslint . --ext .ts --fix",
"ci:lint": "yarn lint && yarn tsc --noEmit",
"ci:unit": "jest --runInBand --ci --coverage",
"dev:unit": "jest --watchAll --runInBand",
"ci:int": "DOTENV_CONFIG_PATH=.env.test jest --config jest.int.config.js --runInBand --ci --coverage",
"dev:int": "DOTENV_CONFIG_PATH=.env.test jest --config jest.int.config.js --watchAll --runInBand"
}
}