From 1f70b67e85bf994b2f38956f49ab31010ca3d9e2 Mon Sep 17 00:00:00 2001 From: Amaad Martin Date: Wed, 29 Jul 2026 15:53:42 -0700 Subject: [PATCH] test(integration): drop the npm install from the AgentLoader discovery fixture The discovery suite never spawns a subprocess: it constructs AgentLoader in-process and calls listApps()/listAgents()/getAppFile(). esbuild and Node both resolve @google/adk and @google/adk-devtools from the workspace-root node_modules, whose symlinks point at the same core/ and dev/ the fixture's file: deps did, so materialising ~600 packages into the fixture was pure waste on every CI job on every OS. Deleting the fixture package.json is required to remove the install, and it changes which manifest getTypeFromPackageJson() finds: the walk now reaches the repository root, which declares "type": "module", so the fixture compiles to .mjs/esm instead of .cjs/cjs. A new assertion on the compiled artifact's extension pins that. Removing the install also stops preloadAgents() stat-ing every top-level entry of a fixture node_modules, and makes the suite runnable offline. --- tests/integration/app_loader/app_loader_test.ts | 14 ++++++++++---- .../integration/app_loader/discovery/package.json | 8 -------- 2 files changed, 10 insertions(+), 12 deletions(-) delete mode 100644 tests/integration/app_loader/discovery/package.json diff --git a/tests/integration/app_loader/app_loader_test.ts b/tests/integration/app_loader/app_loader_test.ts index 1ae34535f..260ee9257 100644 --- a/tests/integration/app_loader/app_loader_test.ts +++ b/tests/integration/app_loader/app_loader_test.ts @@ -68,10 +68,14 @@ describe('AgentLoader discovery and loading integration', () => { ); let loader: AgentLoader; - beforeAll(async () => { - await installFixtureProject(projectPath); + // This fixture is loaded in-process, so it deliberately has no package.json + // and needs no npm install: esbuild and Node both resolve @google/adk from + // the workspace-root node_modules, which points at the same core/ and dev/ + // the fixture's file: deps used to. Without a package.json the fixture + // inherits "type": "module" from the repository root and compiles to ESM. + beforeAll(() => { loader = new AgentLoader(projectPath); - }, FIXTURE_HOOK_TIMEOUT_MS); + }); it( 'should discover apps vs agents across directories and standalone files', @@ -96,6 +100,9 @@ describe('AgentLoader discovery and loading integration', () => { async () => { const appFile = await loader.getAppFile('service_alpha'); const loaded = await appFile.load(); + // Pins the module type the fixture resolves to now that it has no + // package.json of its own: ESM, inherited from the repository root. + expect(path.extname(appFile.getFilePath())).toBe('.mjs'); expect(isApp(loaded)).toBe(true); expect((loaded as App).name).toBe('alpha_app'); @@ -123,6 +130,5 @@ describe('AgentLoader discovery and loading integration', () => { afterAll(async () => { await loader.disposeAll(); - await cleanupFixtureProject(projectPath); }, FIXTURE_HOOK_TIMEOUT_MS); }); diff --git a/tests/integration/app_loader/discovery/package.json b/tests/integration/app_loader/discovery/package.json deleted file mode 100644 index 8b137cf40..000000000 --- a/tests/integration/app_loader/discovery/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "discovery-test", - "version": "1.0.0", - "devDependencies": { - "@google/adk-devtools": "file:../../../../dev", - "@google/adk": "file:../../../../core" - } -}