Intelligence, Advanced Charting & Trading Platform

1 import test from 'node:test';
2 import assert from 'node:assert/strict';
3 import { spawnSync } from 'node:child_process';
4 import { tmpdir } from 'node:os';
5 import { fileURLToPath } from 'node:url';
6
7 // Resolve from this source file, not process.cwd(). This test must also work
8 // under CI, a Windows Desktop Commander shell, and an unrelated launch folder.
9 const runnerPath = fileURLToPath(new URL('../../../scripts/phase1-live-data-proof.mjs', import.meta.url));
10
11 test('live proof runner fails closed without provider credentials, independent of cwd', () => {
12 const env = { ...process.env };
13 delete env.NAVASAN_API_KEY;
14 delete env.ALPHAVANTAGE_API_KEY;
15
16 const run = spawnSync(process.execPath, [runnerPath], {
17 cwd: tmpdir(),
18 env,
19 encoding: 'utf8',
20 timeout: 15_000,
21 });
22
23 assert.equal(run.error, undefined, 'child process must start');
24 assert.notEqual(run.status, 0, 'live data proof must fail closed');
25 assert.match(
26 `${run.stderr ?? ''}\n${run.stdout ?? ''}`,
27 /NAVASAN_API_KEY is required/,
28 );
29 });