Skip to content

Commit

Permalink
add missing video declaration for runner (#4636)
Browse files Browse the repository at this point in the history
* add missing video declaration for runner

* add custom options for encoding

* add default encoding options

* fix typos and add video option for ts runner

* Edit TS defs' descriptions

* Add some options to the test

* Fix the test

Co-authored-by: Vasily Strelyaev <[email protected]>
Co-authored-by: Andrey Belym <[email protected]>
  • Loading branch information
3 people authored Jan 29, 2020
1 parent 8491646 commit 5c23999
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 1 deletion.
19 changes: 18 additions & 1 deletion test/server/data/test-suites/typescript-runner/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,24 @@ test('Starts and terminates runner', async () => {
const remoteConnection = await t.createBrowserConnection();
const runner = t.createRunner();

runner.browsers(remoteConnection);
runner
.browsers(remoteConnection)
.video(
'artifacts/videos',
{
singleFile: true,
failedOnly: false,
ffmpegPath: '/usr/bin/ffmpeg',
pathPattern: '${DATE}-${TIME}'
},
{
'c:v': 'libx264',
'preset': 'ultrafast',
'pix_fmt': 'yuv420p',
'r': 60,
'aspect': '16:9'
}
);

return t.close();
});
92 changes: 92 additions & 0 deletions ts-defs-src/runner-api/runner-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,87 @@ interface ScreenshotsOptions extends TakeScreenshotOptions {
pathPattern?: string;
}

interface VideoOptions {
/**
* Specifies whether to save the entire recording as a single file.
*/
singleFile?: boolean;
/**
* Specifies whether to record only failed tests.
*/
failedOnly?: boolean;
/**
* Specifies the path to the FFmpeg codec executable.
*/
ffmpegPath?: string;
/**
* Specifies a custom pattern that defines how TestCafe composes the relative path to a video file.
*/
pathPattern?: string;
}

interface DefaultEncodingOptions {
/**
* **NOTE:** overwrite output files without asking for a confirmation
* @default true
*/
y: boolean;
/**
* **NOTE:** use the time when a frame is read from the source as its timestamp
*
* **IMPORTANT:** must be specified before configuring the source
* @default 1
*/
'use_wallclock_as_timestamps': number;
/**
* **NOTE:** use stdin as a source
* @default 'pipe:0'
*/
i: string;
/**
* **NOTE:** use the H.264 video codec
* @default 'libx264'
*/
'c:v': string;
/**
* **NOTE:** use the `ultrafast` compression preset
* @default 'ultrafast'
*/
preset: string;

/**
* **NOTE:** use the yuv420p pixel format (the most widely supported)
* @default 'yuv420p'
*/
'pix_fmt': string;
/**
* **NOTE:** scale input frames to make the frame height divisible by 2 (yuv420p's requirement)
* @default 'scale=trunc(iw/2)*2:trunc(ih/2)*2'
*/
vf: string;
/**
* Specifies a custom frame rate (FPS).
* @default 30
*/
r: number;
}

interface VideoEncodingOptions extends Partial<DefaultEncodingOptions> {
/**
* https://ffmpeg.org/ffmpeg.html#Options
*
* custom ffmpeg options
*/
[option: string]: unknown;

/**
* Specifies the video's aspect ratio.
*
* Can be set to '4:3', '16:9', etc.
*/
aspect?: string;
}

interface TestCafe {
/**
* Creates the test runner that is used to configure and launch test tasks.
Expand Down Expand Up @@ -112,6 +193,17 @@ interface Runner {
*/
screenshots(options: ScreenshotsOptions): this;

/**
* https://devexpress.github.io/testcafe/documentation/using-testcafe/common-concepts/screenshots-and-videos.html#basic-video-options
*
* Enables TestCafe to take videos of the tested webpages.
*
* @param path - Output directory
* @param options - Video options
* @param encodingOptions - Video encoding options
*/
video(path: string, options?: VideoOptions, encodingOptions?: VideoEncodingOptions): this;

/**
* Configures TestCafe's reporting feature.
*
Expand Down

0 comments on commit 5c23999

Please sign in to comment.