(
testName: string,
options: { settings?: Record<string, unknown> } = {},
)
| 130 | } |
| 131 | |
| 132 | setup( |
| 133 | testName: string, |
| 134 | options: { settings?: Record<string, unknown> } = {}, |
| 135 | ) { |
| 136 | this.testName = testName; |
| 137 | const sanitizedName = sanitizeTestName(testName); |
| 138 | this.testDir = join(env.INTEGRATION_TEST_FILE_DIR!, sanitizedName); |
| 139 | mkdirSync(this.testDir, { recursive: true }); |
| 140 | |
| 141 | // Create a settings file to point the CLI to the local collector |
| 142 | const anusDir = join(this.testDir, '.anus'); |
| 143 | // Ensure non-interactive Grok provider is used by default for these tests |
| 144 | // Write a minimal settings.json with provider and dummy model |
| 145 | try { |
| 146 | mkdirSync(anusDir, { recursive: true }); |
| 147 | writeFileSync( |
| 148 | join(anusDir, 'settings.json'), |
| 149 | JSON.stringify({ |
| 150 | provider: 'grok', |
| 151 | model: 'grok-beta', |
| 152 | grok: { model: 'grok-beta' }, |
| 153 | }), |
| 154 | 'utf-8', |
| 155 | ); |
| 156 | } catch { |
| 157 | // best-effort; env-based detection should still work |
| 158 | } |
| 159 | mkdirSync(anusDir, { recursive: true }); |
| 160 | // In sandbox mode, use an absolute path for telemetry inside the container |
| 161 | // The container mounts the test directory at the same path as the host |
| 162 | const telemetryPath = |
| 163 | env.ANUS_SANDBOX && env.ANUS_SANDBOX !== 'false' |
| 164 | ? join(this.testDir, 'telemetry.log') // Absolute path in test directory |
| 165 | : env.TELEMETRY_LOG_FILE; // Absolute path for non-sandbox |
| 166 | |
| 167 | const settings = { |
| 168 | telemetry: { |
| 169 | enabled: true, |
| 170 | target: 'local', |
| 171 | otlpEndpoint: '', |
| 172 | outfile: telemetryPath, |
| 173 | }, |
| 174 | sandbox: env.ANUS_SANDBOX !== 'false' ? env.ANUS_SANDBOX : false, |
| 175 | ...options.settings, // Allow tests to override/add settings |
| 176 | }; |
| 177 | writeFileSync( |
| 178 | join(anusDir, 'settings.json'), |
| 179 | JSON.stringify(settings, null, 2), |
| 180 | ); |
| 181 | } |
| 182 | |
| 183 | createFile(fileName: string, content: string) { |
| 184 | const filePath = join(this.testDir!, fileName); |
no test coverage detected