@ordojs/core
Version:
Core compiler and runtime for OrdoJS framework
133 lines • 3.82 kB
TypeScript
/**
* @fileoverview End-to-End Testing Utilities for OrdoJS Framework
*
* This module provides a wrapper around Playwright for E2E testing.
* It allows for browser-based testing of OrdoJS applications.
*/
import type { E2ETestConfig, TestResult } from './types.js';
/**
* End-to-End testing utilities for OrdoJS applications
*
* This class provides a simplified interface for E2E testing using Playwright.
* It's designed to be used with the OrdoJS testing framework.
*/
export declare class E2ETestUtils {
private config;
private browser;
private context;
private page;
private isInitialized;
constructor(config: E2ETestConfig);
/**
* Initialize the E2E testing environment
*
* This method sets up Playwright and launches a browser instance.
* It should be called before running any tests.
*/
initialize(): Promise<void>;
/**
* Clean up the E2E testing environment
*
* This method closes the browser and cleans up resources.
* It should be called after all tests are complete.
*/
cleanup(): Promise<void>;
/**
* Navigate to a URL
*
* @param url - The URL to navigate to (relative to baseUrl)
*/
navigateTo(url: string): Promise<void>;
/**
* Get the current URL
*/
getCurrentUrl(): string;
/**
* Fill a form field
*
* @param selector - CSS selector for the form field
* @param value - Value to fill in the form field
*/
fillField(selector: string, value: string): Promise<void>;
/**
* Click an element
*
* @param selector - CSS selector for the element to click
*/
click(selector: string): Promise<void>;
/**
* Wait for an element to be visible
*
* @param selector - CSS selector for the element to wait for
* @param timeout - Maximum time to wait in milliseconds
*/
waitForElement(selector: string, timeout?: number): Promise<void>;
/**
* Wait for a condition to be true
*
* @param condition - Function that returns a boolean or Promise<boolean>
* @param timeout - Maximum time to wait in milliseconds
*/
waitForCondition(condition: () => boolean | Promise<boolean>, timeout?: number): Promise<void>;
/**
* Take a screenshot
*
* @param name - Name of the screenshot file
*/
takeScreenshot(name: string): Promise<void>;
/**
* Get text content of an element
*
* @param selector - CSS selector for the element
*/
getText(selector: string): Promise<string>;
/**
* Check if an element exists
*
* @param selector - CSS selector for the element
*/
elementExists(selector: string): Promise<boolean>;
/**
* Run an E2E test
*
* @param testFn - Test function to run
* @param name - Name of the test
*/
runTest(testFn: () => Promise<void>, name: string): Promise<TestResult>;
/**
* Run multiple E2E tests
*
* @param tests - Array of test objects with name and test function
*/
runTests(tests: Array<{
name: string;
testFn: () => Promise<void>;
}>): Promise<TestResult[]>;
/**
* Ensure that the E2E environment is initialized
*/
private ensureInitialized;
/**
* Create a new page in the browser context
*/
newPage(): Promise<any>;
/**
* Execute JavaScript in the browser context
*
* @param script - JavaScript code to execute
*/
evaluateScript<T>(script: string | Function): Promise<T>;
/**
* Get the browser instance
*/
getBrowser(): any;
/**
* Get the browser context
*/
getContext(): any;
/**
* Get the current page
*/
getPage(): any;
}
//# sourceMappingURL=e2e-test.d.ts.map