Skip to content

Commit 25021aa

Browse files
jdaltonclaude
andcommitted
chore(test): enhance test configuration with socket-sdk-js optimizations
- Add cacheDir configuration to vitest for better cache management - Add bail: 1 for faster CI failures on first error - Add sequence.concurrent for parallel test execution within suites - Add fork pool options for tests requiring isolation - Set COVERAGE env var for test coverage mode detection - Update CI workflow to latest socket-registry SHA (f2f356c8) These optimizations improve test execution speed and resource management while maintaining test isolation where needed. Tests can now opt into fork isolation via { pool: 'forks' } when required. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 05cce78 commit 25021aa

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

.config/vitest.config.mts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ const isCoverageEnabled =
1313
process.env.npm_lifecycle_event?.includes('coverage') ||
1414
process.argv.some(arg => arg.includes('coverage'))
1515

16+
// Set environment variable so tests can detect coverage mode
17+
if (isCoverageEnabled) {
18+
process.env.COVERAGE = 'true'
19+
}
20+
1621
export default defineConfig({
22+
cacheDir: './.cache/vitest',
1723
resolve: {
1824
alias: getLocalPackageAliases(path.join(__dirname, '..')),
1925
},
@@ -26,6 +32,14 @@ export default defineConfig({
2632
// Use threads for better performance
2733
pool: 'threads',
2834
poolOptions: {
35+
forks: {
36+
// Configuration for tests that opt into fork isolation via { pool: 'forks' }
37+
// During coverage, use multiple forks for better isolation
38+
singleFork: false,
39+
maxForks: isCoverageEnabled ? 4 : 16,
40+
minForks: isCoverageEnabled ? 1 : 2,
41+
isolate: true,
42+
},
2943
threads: {
3044
// Use single thread for coverage to reduce memory, parallel otherwise.
3145
singleThread: isCoverageEnabled,
@@ -54,6 +68,14 @@ export default defineConfig({
5468
// Reduce timeouts for faster failures
5569
testTimeout: 10_000,
5670
hookTimeout: 10_000,
71+
// Speed optimizations
72+
// Note: cache is now configured via Vite's cacheDir
73+
sequence: {
74+
// Run tests concurrently within suites
75+
concurrent: true,
76+
},
77+
// Bail early on first failure in CI
78+
bail: process.env.CI ? 1 : 0,
5779
coverage: {
5880
provider: 'v8',
5981
reporter: ['text', 'json', 'html', 'lcov', 'clover'],

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ permissions:
1717
jobs:
1818
ci:
1919
name: Run CI Pipeline
20-
uses: SocketDev/socket-registry/.github/workflows/ci.yml@d8ff3b0581d799466cfbf150f715c1a4bf9f84a5 # main
20+
uses: SocketDev/socket-registry/.github/workflows/ci.yml@f2f356c861eeac6d750bf2f87225cdcf2bc1a29f # main
2121
with:
2222
fail-fast: false
2323
lint-script: 'pnpm run lint-ci'

0 commit comments

Comments
 (0)