import { LaunchOptions , ViewportSize } from 'playwright' ; import { BrowserType } from '../page/types' ; import ms from 'ms' ; import { DeviceDescriptor } from '../page/Device' ; export param { TestSettings } settings export declare function setup ( settings ) ; export const DEFAULT_STEP_WAIT_MILLISECONDS = 5000 ; export const DEFAULT_ACTION_WAIT_MILLISECONDS = 500 ; export const DEFAULT_WAIT_TIMEOUT_MILLISECONDS = 30000 ; export const DEFAULT_ACTION_DELAY = 2000 ; export const DEFAULT_STEP_DELAY = 6000 ; export const DEFAULT_DURATION = - 1 ; export const DEFAULT_STEP_DELAY_FAST_FORWARD = 1000 ; export const DEFAULT_ACTION_DELAY_FAST_FORWARD = 1000 ; export const DEFAULT_STEP_DELAY_SLOW_MO = 10000 ; export const DEFAULT_ACTION_DELAY_SLOW_MO = 10000 ; /**
 * Specifies a method for recording response times.
 *
 * literal | description
 * --------|------------
 * step | (Default) Records the wall clock time of a step. This is useful for Single Page Application which don't actually trigger a navigation.
 * page | Record the document loading response time. This is usually what you consider response time on paged web apps.
 * network | (Experimental) Takes the mean response time of all network requests which occur during a step. This is useful for Single Page Application which don't actually trigger a navigation.
 * stepWithThinkTime | `"stepWithThinkTime"`: Records the wall clock time of a step including `actionDelay` time.
 */ export type ResponseTiming = 'page' | 'network' | 'step' | 'stepWithThinkTime' ; /**
 * Specifies a `console` method
 */ export type ConsoleMethod = 'log' | 'info' | 'debug' | 'warn' | 'error' ; /**
 * Element presence lists the accepted values for automatically waiting on elements before running actions.
 *
 * - visible: waits until the element is visible on the page and is painted
 * - present: only checks for presence in the DOM
 * - ready: waits until the element is painted and not disabled
 *
 * Set to `false` or `null` to disable.
 */ export type ElementPresence = 'visible' | 'present' | 'ready' | false | null ; export type BrowserLaunchOptions = LaunchOptions ; /**
 * The TestSettings interface specifies the available settings you have to configure how your test runs. These properties should be exported using the property `settings`.
 *
 * **Example:**
 *
 * ```typescript
 * export const settings: TestSettings = {
 *   loopCount: Infinity,
 *   clearCache: true
 * }
 * ```
 *
 * See [DEFAULT_SETTINGS] for a list of the default value for each setting.
 */ export interface TestSettings { /**
     * Maximum duration to run the test for.
     *
     * Note that when running a load test via https://flood.io, the duration of the load test takes precedence over this setting.
     *
     * Defaults to `-1` for no timeout.
     */ duration ? : string | number ; /**
     * Number of times to run this test.
     *
     * Defaults to `-1` for an unlimited number of loops.
     */ loopCount ? : number ; /**
     * Specifies the time (in seconds) to wait between each action call.
     *
     * Waiting between actions simulates the behaviour of a real user as they read, think and act on the page's content.
     */ actionDelay ? : string | number ; /**
     * Specifies the time (in seconds) to wait after each step.
     */ stepDelay ? : string | number ; /**
     * Specifies a custom User Agent (UA) string to send.
     */ userAgent ? : string ; /**
     * Specifies a device to emulate with browser device emulation.
     */ device ? : DeviceDescriptor | null ; param viewport viewport ? : ViewportSize | null ; /**
     * Global wait timeout applied to all wait tasks.
     */ waitTimeout ? : number | string ; default clearCookies ? : boolean ; default clearCache ? : boolean ; /**
     * Disables browser request cache for all requests.
     */ disableCache ? : boolean ; default extraHTTPHeaders ? : { [ key ] : string ; } ; default name ? : string ; default description ? : string ; /**
     * Take a screenshot of the page when a command fails, to aid in debugging.
     *
     * Screenshots are saved to `/flood/result/screenshots` in the test archive.
     */ screenshotOnFailure ? : boolean ; /**
     * Configures how we record response time for each step.
     *
     * Possible values:
     * - `"page"`: Record the document loading response time. This is usually what you consider response time on paged web apps.
     * - `"network"`: Takes the mean response time of all network requests which occur during a step. This is useful for Single Page Application which don't actually trigger a navigation.
     * - `"step"`: (Default) Records the wall clock time of a step. This is useful for Single Page Application which don't actually trigger a navigation.
     * - `"stepWithThinkTime"`: Records the wall clock time of a step including `actionDelay` time.
     */ responseTimeMeasurement ? : ResponseTiming ; /**
     * Specify which console methods to filter out. By default no console methods are filtered.
     *
     * This setting can be useful for very noisy tests. When a method is filtered, it still works as normal but the message will be omitted from the Element output.
     */ consoleFilter ? : ConsoleMethod [ ] ; /**
     * Whether to ignore HTTPS errors during navigation. Defaults to `false`
     */ ignoreHTTPSError ? : boolean ; /**
     * Controls whether each iteration should run within an Incognito window instead of a normal
     * window. The Incognito session will be destroyed between each loop.
     */ incognito ? : boolean ; /**
     * Specifies a version of Google Chrome
     */ browser ? : BrowserType ; /**
     * Specifies options to launch
     */ browserLaunchOptions ? : BrowserLaunchOptions ; /**

     * Blocks requests to a list a domains. Accepts partial matches using `*` or any matcher accepted by [Micromatch](https://github.com/micromatch/micromatch)
     *
     * Matching is applied to the `hostname` only, unless the blocked domain contains a `:` in which case it will match against `hostname` and `port`.
     *
     * Example:
     *
     * `["*.google-analytics.com", "*:1337"]`
     */ blockedDomains ? : string [ ] ; /**
     * Automatically apply a wait(Until...) before each action. Defaults to `false`
     *
     * Accepts either `visible` or `present` as values. Set to `false` to disable (default).
     *
     * Uses global wait timeout from settings.
     */ waitUntil ? : ElementPresence ; /**
     * Additional arguments to pass to the browser instance.
     * The list of Chromium flags can be found at https://peter.sh/experiments/chromium-command-line-switches/
     */ launchArgs ? : string [ ] ; /**
     * Define the loop count of the recovery step
     */ tries ? : number ; /**
     * Specifies the steps for ramping up and down load
     */ stages ? : RampStage [ ] ; /**
     * show screenshot on terminal (iTerm only)
     */ showScreenshot ? : boolean ; } export type RampStage = { duration : string ; target : number ; } ; /**
 * The default settings for a Test. Any settings you provide are merged into these defaults.
 */ export const DEFAULT_SETTINGS = { waitUntil : false , duration : - 1 , loopCount : - 1 , actionDelay : 2000 , stepDelay : 6000 , screenshotOnFailure : false , clearCookies : true , clearCache : false , waitTimeout : 30000 , responseTimeMeasurement : 'step' , tries : 0 , /**
     * by default, don't filter any console messages from the browser
     */ consoleFilter : [ ] , userAgent : '' , device : null , ignoreHTTPSError : false , browser : 'chromium' , browserLaunchOptions : { } , blockedDomains : [ ] , incognito : false , name : 'Element Test' , description : '' , disableCache : false , extraHTTPHeaders : { } , launchArgs : [ ] , viewport : { width : 1440 , height : 900 } , stages : [ ] , showScreenshot : false , } ; internal export type ConcreteTestSettings = Required < TestSettings > ; internal export function normalizeSettings ( settings ) { let convertedWaitTimeout = DEFAULT_WAIT_TIMEOUT_MILLISECONDS ; let convertedActionDelay = DEFAULT_ACTION_DELAY ; let convertedStepDelay = DEFAULT_STEP_DELAY ; let convertedDuration = DEFAULT_DURATION ; if ( settings . waitTimeout ) { if ( typeof settings . waitTimeout === 'string' ) { convertedWaitTimeout = ms ( settings . waitTimeout ) ; } else { convertedWaitTimeout = settings . waitTimeout ; if ( convertedWaitTimeout < 0 ) convertedWaitTimeout = DEFAULT_WAIT_TIMEOUT_MILLISECONDS ; if ( convertedWaitTimeout < 1e3 ) convertedWaitTimeout *= 1e3 ; } } settings . waitTimeout = convertedWaitTimeout ; if ( settings . actionDelay ) { if ( typeof settings . actionDelay === 'string' ) { convertedActionDelay = ms ( settings . actionDelay ) ; } else { convertedActionDelay = settings . actionDelay ; if ( convertedActionDelay < 0 ) convertedActionDelay = DEFAULT_ACTION_DELAY ; if ( convertedActionDelay < 1e3 ) convertedActionDelay *= 1e3 ; } } settings . actionDelay = convertedActionDelay ; if ( settings . stepDelay ) { if ( typeof settings . stepDelay === 'string' ) { convertedStepDelay = ms ( settings . stepDelay ) ; } else { convertedStepDelay = settings . stepDelay ; if ( convertedStepDelay < 0 ) convertedStepDelay = DEFAULT_STEP_DELAY ; if ( convertedStepDelay < 1e3 ) convertedStepDelay *= 1e3 ; } } settings . stepDelay = convertedStepDelay ; if ( settings . duration ) { if ( typeof settings . duration === 'string' ) { convertedDuration = ms ( settings . duration ) ; } else { convertedDuration = settings . duration ; if ( convertedDuration < 0 ) convertedDuration = DEFAULT_DURATION ; if ( convertedDuration < 1e3 ) convertedDuration *= 1e3 ; } } settings . duration = convertedDuration ; return settings ; }