Home / File/ integration.test.ts — dead-code-hunter Source File

integration.test.ts — dead-code-hunter Source File

Architecture documentation for integration.test.ts, a typescript file in the dead-code-hunter codebase. 7 imports, 0 dependents.

File typescript GitHubAction ActionEntry 7 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  e24069d3_01df_965c_4846_7b5d20bf2edd["integration.test.ts"]
  a3eb2ced_926a_5c50_f1b5_fa2919e7f56f["dead-code.ts"]
  e24069d3_01df_965c_4846_7b5d20bf2edd --> a3eb2ced_926a_5c50_f1b5_fa2919e7f56f
  8fb39060_bdfd_d045_ece4_18fee517d989["filterByIgnorePatterns"]
  e24069d3_01df_965c_4846_7b5d20bf2edd --> 8fb39060_bdfd_d045_ece4_18fee517d989
  2e5ab91f_dab4_67de_047b_0f558da37c4e["vitest"]
  e24069d3_01df_965c_4846_7b5d20bf2edd --> 2e5ab91f_dab4_67de_047b_0f558da37c4e
  c6b90f19_f457_b900_77cb_5f872707017c["child_process"]
  e24069d3_01df_965c_4846_7b5d20bf2edd --> c6b90f19_f457_b900_77cb_5f872707017c
  da7c4e79_9b8f_97ab_76e7_1e8697905bff["promises"]
  e24069d3_01df_965c_4846_7b5d20bf2edd --> da7c4e79_9b8f_97ab_76e7_1e8697905bff
  df4e45ee_2d39_ee0d_c278_4a72a71d8cd0["path"]
  e24069d3_01df_965c_4846_7b5d20bf2edd --> df4e45ee_2d39_ee0d_c278_4a72a71d8cd0
  6ae50d5c_b484_7217_ed63_710361d1134f["sdk"]
  e24069d3_01df_965c_4846_7b5d20bf2edd --> 6ae50d5c_b484_7217_ed63_710361d1134f
  style e24069d3_01df_965c_4846_7b5d20bf2edd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { describe, it, expect, beforeAll } from 'vitest';
import { execSync } from 'child_process';
import * as fs from 'fs/promises';
import * as path from 'path';
import { Configuration, DefaultApi } from '@supermodeltools/sdk';
import type { DeadCodeAnalysisResponseAsync, DeadCodeAnalysisResponse } from '@supermodeltools/sdk';
import { filterByIgnorePatterns } from '../dead-code';

const API_KEY = process.env.SUPERMODEL_API_KEY;
const SKIP_INTEGRATION = !API_KEY;

async function pollForResult(
  api: DefaultApi,
  idempotencyKey: string,
  zipBlob: Blob,
  timeoutMs = 120_000
): Promise<DeadCodeAnalysisResponse> {
  const startTime = Date.now();

  for (let attempt = 1; attempt <= 30; attempt++) {
    const response: DeadCodeAnalysisResponseAsync = await api.generateDeadCodeAnalysis({
      idempotencyKey,
      file: zipBlob,
    });

    if (response.status === 'completed' && response.result) {
      return response.result;
    }

    if (response.status === 'failed') {
      throw new Error(`Analysis job failed: ${response.error || 'unknown error'}`);
    }

    if (Date.now() - startTime >= timeoutMs) {
      throw new Error(`Polling timed out after ${timeoutMs}ms`);
    }

    const retryMs = (response.retryAfter ?? 10) * 1000;
    await new Promise(resolve => setTimeout(resolve, retryMs));
  }

  throw new Error('Max polling attempts exceeded');
}

describe.skipIf(SKIP_INTEGRATION)('Integration Tests', () => {
  let api: DefaultApi;
  let zipPath: string;
  let idempotencyKey: string;
  let result: DeadCodeAnalysisResponse;

  beforeAll(async () => {
    const config = new Configuration({
      basePath: process.env.SUPERMODEL_BASE_URL || 'https://api.supermodeltools.com',
      apiKey: API_KEY!,
    });
    api = new DefaultApi(config);

    const repoRoot = path.resolve(__dirname, '../..');
    zipPath = '/tmp/dead-code-hunter-test.zip';

// ... (71 more lines)

Domain

Subdomains

Functions

Dependencies

Frequently Asked Questions

What does integration.test.ts do?
integration.test.ts is a source file in the dead-code-hunter codebase, written in typescript. It belongs to the GitHubAction domain, ActionEntry subdomain.
What functions are defined in integration.test.ts?
integration.test.ts defines 1 function(s): pollForResult.
What does integration.test.ts depend on?
integration.test.ts imports 7 module(s): child_process, dead-code.ts, filterByIgnorePatterns, path, promises, sdk, vitest.
Where is integration.test.ts in the architecture?
integration.test.ts is located at src/__tests__/integration.test.ts (domain: GitHubAction, subdomain: ActionEntry, directory: src/__tests__).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free