arda-site-scan
Version:
A standalone CLI tool for comprehensive website analysis including screenshots, SEO, and accessibility testing using Playwright
112 lines • 3.65 kB
TypeScript
/**
* Test Output Type System
*
* Defines standardized output behavior for all test types, ensuring consistent
* file generation and result handling across the application.
*/
export type TestOutputType = 'per-page' | 'site-wide';
/**
* Configuration for how a test should handle output generation
*/
export interface OutputConfiguration {
/** Type of output this test generates */
type: TestOutputType;
/** File extension for output files (without dot) */
fileExtension: string;
/** Subdirectory within page/session directory for organizing files */
subdirectory?: string;
/** Custom filename pattern (use {pageName}, {sessionId}, {testType} placeholders) */
filenamePattern?: string;
/** Whether this output should be included in HTML reports */
includeInReports: boolean;
/** MIME type for the output file */
mimeType?: string;
}
/**
* Result of an output operation
*/
export interface OutputResult {
/** Whether the output operation was successful */
success: boolean;
/** Full path to the generated output file */
outputPath?: string;
/** Error message if operation failed */
error?: string;
/** Size of generated file in bytes */
fileSize?: number;
/** Additional metadata about the output */
metadata?: Record<string, any>;
}
/**
* Interface for handling test output operations
*/
export interface TestOutputHandler {
/**
* Generate the appropriate output path for a test
*/
generateOutputPath(sessionId: string, testType: string, config: OutputConfiguration, context: OutputContext): string;
/**
* Save content to the appropriate location
*/
saveOutput(content: string | Buffer, outputPath: string, config: OutputConfiguration): Promise<OutputResult>;
/**
* Ensure the necessary directories exist for the output
*/
ensureOutputDirectory(outputPath: string): Promise<void>;
/**
* Get relative path for use in reports and links
*/
getRelativePath(outputPath: string, basePath: string): string;
}
/**
* Context information for generating output paths and filenames
*/
export interface OutputContext {
/** URL being tested (for per-page tests) */
url?: string;
/** Page name derived from URL */
pageName?: string;
/** Viewport name (for screenshot tests) */
viewport?: string;
/** Additional context data specific to the test */
additionalData?: Record<string, any>;
}
/**
* Predefined output configurations for common test types
*/
export declare const OUTPUT_CONFIGURATIONS: Record<string, OutputConfiguration>;
/**
* Utility functions for working with output types
*/
export declare class OutputTypeUtils {
/**
* Check if a test type generates per-page output
*/
static isPerPageTest(testType: string): boolean;
/**
* Check if a test type generates site-wide output
*/
static isSiteWideTest(testType: string): boolean;
/**
* Get the output configuration for a test type
*/
static getOutputConfig(testType: string): OutputConfiguration | undefined;
/**
* Replace placeholders in filename patterns
*/
static replacePlaceholders(pattern: string, context: {
pageName?: string;
sessionId?: string;
testType?: string;
viewport?: string;
[key: string]: any;
}): string;
/**
* Validate that an output configuration is properly formed
*/
static validateOutputConfig(config: OutputConfiguration): {
valid: boolean;
errors: string[];
};
}
//# sourceMappingURL=test-output-types.d.ts.map