import { Test } from '@nestjs/testing'; import { describe, expect, it } from 'vitest'; import { MeshService } from '../mesh/mesh.service.js'; import { BatteryAlertModule } from './battery.module.js'; import { BatteryAlertService } from './battery.service.js'; describe('DI wiring (module graph)', () => { // compile() instantiates providers but does not run lifecycle hooks, so no TCP connection is opened. it('resolves BatteryAlertService with MeshService provided by MeshModule', async () => { process.env.MESH_DB_PATH = ':memory:'; // keep openMessageDb from touching the repo's ./data const moduleRef = await Test.createTestingModule({ imports: [BatteryAlertModule], }).compile(); expect(moduleRef.get(BatteryAlertService)).toBeInstanceOf( BatteryAlertService, ); expect(moduleRef.get(MeshService)).toBeInstanceOf(MeshService); }); });