diff --git a/tests/integration/api-parameter-validation.test.ts b/tests/integration/api-parameter-validation.test.ts index 4e25e781..da4aed14 100644 --- a/tests/integration/api-parameter-validation.test.ts +++ b/tests/integration/api-parameter-validation.test.ts @@ -34,6 +34,10 @@ describe('API Parameter Validation', () => { }) }) + afterAll(async () => { + await brain.close() + }) + it('should use "where" parameter for metadata filtering', async () => { const results = await brain.find({ where: { category: 'test-category' }, diff --git a/tests/integration/entity-confidence-weight.test.ts b/tests/integration/entity-confidence-weight.test.ts index b5bb34c5..031d29f1 100644 --- a/tests/integration/entity-confidence-weight.test.ts +++ b/tests/integration/entity-confidence-weight.test.ts @@ -7,7 +7,7 @@ * - Backward compatibility preserved */ -import { describe, it, expect, beforeEach } from 'vitest' +import { describe, it, expect, beforeEach, afterEach } from 'vitest' import { Brainy } from '../../src/brainy.js' import { NounType } from '../../src/types/graphTypes.js' @@ -19,6 +19,10 @@ describe('Entity Confidence & Weight Exposure', () => { await brain.init() }) + afterEach(async () => { + await brain.close() + }) + describe('Entity interface', () => { it('should expose confidence when adding entity with confidence', async () => { const id = await brain.add({ diff --git a/tests/integration/related-verb-array.test.ts b/tests/integration/related-verb-array.test.ts index 36a49850..7ed1bd3f 100644 --- a/tests/integration/related-verb-array.test.ts +++ b/tests/integration/related-verb-array.test.ts @@ -30,6 +30,7 @@ describe('related() with a verb-type array returns every requested type', () => }) afterAll(async () => { + await brain.close() brain = null as any }) diff --git a/tests/integration/relationship-intelligence.test.ts b/tests/integration/relationship-intelligence.test.ts index b6e11cb5..c18057fb 100644 --- a/tests/integration/relationship-intelligence.test.ts +++ b/tests/integration/relationship-intelligence.test.ts @@ -59,7 +59,8 @@ describe('Relationship Intelligence', () => { await brain.init() }) - afterEach(() => { + afterEach(async () => { + await brain.close() if (fs.existsSync(testDir)) { fs.rmSync(testDir, { recursive: true }) } diff --git a/tests/integration/rev-and-ifabsent.test.ts b/tests/integration/rev-and-ifabsent.test.ts index 64b184a3..3bff59f1 100644 --- a/tests/integration/rev-and-ifabsent.test.ts +++ b/tests/integration/rev-and-ifabsent.test.ts @@ -9,7 +9,7 @@ * - addMany({ ifAbsent: true }) applies the flag to every item */ -import { describe, it, expect, beforeEach } from 'vitest' +import { describe, it, expect, beforeEach, afterEach } from 'vitest' import { Brainy } from '../../src/brainy.js' import { RevisionConflictError } from '../../src/transaction/RevisionConflictError.js' import { NounType } from '../../src/types/graphTypes.js' @@ -22,6 +22,10 @@ describe('7.31.0 — _rev CAS + ifAbsent', () => { await brain.init() }) + afterEach(async () => { + await brain.close() + }) + describe('_rev initialization + surface', () => { it('initializes _rev to 1 on add()', async () => { const id = await brain.add({ data: 'hello', type: NounType.Document }) diff --git a/tests/integration/vfs-containment-batched.test.ts b/tests/integration/vfs-containment-batched.test.ts index 0a7919bf..7bbad478 100644 --- a/tests/integration/vfs-containment-batched.test.ts +++ b/tests/integration/vfs-containment-batched.test.ts @@ -81,6 +81,7 @@ describe('repairContainment: batched pass 2', () => { }) afterAll(async () => { + await brain.close() brain = null as any }) diff --git a/tests/integration/vfs-debug.test.ts b/tests/integration/vfs-debug.test.ts index 7e781139..5eeb0ef5 100644 --- a/tests/integration/vfs-debug.test.ts +++ b/tests/integration/vfs-debug.test.ts @@ -9,9 +9,10 @@ import * as XLSX from 'xlsx' describe('VFS Debug', () => { it('minimal VFS writeFile test', async () => { const brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } }) - await brain.init() + try { + await brain.init() - console.log('✅ Brain initialized') + console.log('✅ Brain initialized') // Get VFS and initialize const vfs = brain.vfs @@ -77,5 +78,8 @@ describe('VFS Debug', () => { // THE REAL TEST: Can we query VFS? expect(children.length).toBeGreaterThan(0) expect(rootContents.length).toBeGreaterThan(0) + } finally { + await brain.close() + } }) })